我想从URL中检索XML并将其存储在变量xmlDoc
中。带有URL的XML http请求
我有以下几点:
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","localhost:8080/rest/xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
但我没有得到的XML文件,是不是我需要补充的吗?
你或许应该看一些例子,Ajax请求的异步,所以你要听的onreadystate事件来捕获响应 – adeneo
[这是一个例子。](http://www.quirksmode.org/js/xmlhttp.html) – Andy