【已解决】IDE中支持XMLHttpRequest吗?向其它服务器请求数据status返回0

始终无法获取数据,代码如下:


var xmlObj = new XMLHttpRequest();
function createXMLHttpRequest(){
if(window.ActiveXObject){
try{
xmlobj = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
}catch(E){
xmlobj = false;
}
}
}else if(window.XMLHttpRequest){
xmlobj = new XMLHttpRequest();
}
}

function myPost(cityName){
createXMLHttpRequest();
//var _host ='ws.webxml.com.cn';
//var _post = '/WebServices/WeatherWS.asmx/getWeather';
//var url = _host + _post;
//var url = 'ws.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather';
var url = 'ws.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather?theCityCode=北京&theUserID=';
//var pram = 'theCityCode='+cityName;
xmlObj.onreadystatechange = onResponse;
xmlObj.open("GET",url,true);
//xmlObj.setRequestHeader('Content-Type','text/xml');
//xmlObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//xmlObj.setRequestHeader('Content-Length',pram.length);
xmlObj.send(null);
}

function onResponse()
{
var scene = mugeda.scene;
var txt = scene.getObjectByName('txt');
txt.text = ' ['+xmlObj.status+'] ::';
txt.text += xmlObj.responseXML;
}

mugeda.addEventListener('renderReady',function(){
myPost('');

});
已邀请:

test099

赞同来自:

不好意思,论坛暂时不做代码方面的帮助,你可以看看http://bbs.mugeda.com/?/article/289这里api的文档

ddbackhome

赞同来自:

请用  jsonp 的返回格式

要回复问题请先登录注册