Possible Duplicate:
XMLHttpRequest.responseText doesnt write the value when calling a URL
I ve written the code in both javascript and jquery to call a URL and get the return value by referring here and here.
但是,牛页的回报值在我的html档案中显示。 自2006年以来 我要问一下,我是否需要把呼吁作为交叉张贴? 如果是的话,你能否解释我?
www.un.org/Depts/DGACM/index_spanish.htm Java印代码为。
<script type="text/javascript" >
var req ;
// Browser compatibility check
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
var req = new XMLHttpRequest();
req.open("GET", "http://www.example.com/Default.aspx?usrname=john",true);
req.onreadystatechange = function () {
document.getElementById( divTxt ).innerHTML = "My Status: " + req.responseText;
}
req.send(null);
</script>
</script>
<html>
<head/>
<body>
<div id="divTxt"></div></body>
</html>
The output I get is : My Status :
The JQuery code is
var html = $.ajax({
url: "http://www.example.com/Default.aspx?usrname=john",
async: true
}).responseText;
document.getElementById( divTxt ).innerHTML = "My Status: " + html;
The output I get is blank page
PS:我是。 由于我的问题没有得到适当回答,这个问题再次出现。
** 本文件迟交。 本文件迟交。
> EDIT: in my original code, there is
http://
** 本文件迟交。 本文件迟交。