我本地测试可以取到远程的XML文件数据,楼主出示部分代码

解决方案 »

  1.   

    <SCRIPT language=JavaScript>
    /* Create a new XMLHttpRequest object to talk to the Web server */
    var xmlHttp = false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
        xmlHttp = false;
      }
    }
    @end @*/
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
      xmlHttp = new XMLHttpRequest();
    }
    function callServer() {  var url = "http://wap.hao123.com/index.jsp?ssid=anonymous"
      xmlHttp.open("GET", url, true);  xmlHttp.onreadystatechange = updatePage;  xmlHttp.send(null);
    }function updatePage()
    {
      if (xmlHttp.readyState == 4) {
        var response = xmlHttp.responseText;
        NowT.innerHTML = response;
      }
    }
    setTimeout("callServer()",50);
    </SCRIPT>
    <FONT Id="NowT" color="#999999"></FONT>
      

  2.   

    这涉及到一个安全问题,比较简单的处理方法是你在你的服务器端搞一个jsp之类的页面,将你需要的远程的XML文件数据拿过来,然后再给你的ajax。也就是说你的ajax请求的还是你的页面,只不过你的后台页面又去溜了一下将别人的页面拿过来了:)