【求助-急】-- js 调用webservice返回空,并且status为0

qq_18540635 qq_18540635 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
js调用webservice status一直为0,改为天气这个web服务后,还是为0,是哪出问题了,求助,急。下面贴下代码

var xmlhttp;
function RequestByPost() {
var URL = "http://www.webxml.com.cn/WebServices/WeatherWS.asmx";

//在这处我们拼接
var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">';
data = data + '<soap12:Body>';
data = data + '<getRegionCountry xmlns="http://tempuri.org/" />';
data = data + '</soap12:Body>';
data = data + '</soap12:Envelope>';

//创建异步对象
var xmlhttp = createXmlHttpRequest();
xmlhttp.open("POST", URL, true);
xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8");
xmlhttp.send(data);

// alert(xmlhttp.responseText);

}

function createXmlHttpRequest() {

if (window.XMLHttpRequest) {
xmlhttp = new window.XMLHttpRequest()
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHttp");
}
return xmlhttp;
}

function callback() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200 ) { //xmlhttp.status为0,可这个已经发布了啊
var response = xmlhttp.responseText;
alert(response);
}
}
}
...全文
评论 2
收藏 已收藏
分享
返回顶部
qq_18540635
JavaScript 87,983 成员 224,681 内容