dongxingguo1978 2013-05-21 16:48
浏览 21

AJAX从另一台服务器获取数据时失败

I read AJAX does not work with remote but found solution but still facing How to do it with Pure AJAX, Any guide?? I searched a lot and tried some methods, but did not get. When I am using same IP and fetching data ,its working with warning,but when giving another server IP, it does not fetch .

function tooltipajax(r_ID) {
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById('span'+ r_ID).innerHTML = xmlhttp.responseText;
        }
    }

    xmlhttp.open("GET","http://ip here/common/accounteditajax.php?key=" +r_ID,true);
    xmlhttp.send();
} 

I tried HEADER

header("Access-control-Allow-Origin: http://IP HERE/common/");

it worked for local server with ip with warning Cannot modify header information - headers already sent by (output started at

But not working with another server ip..

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改