【求助-急】-- js 调用webservice返回空,并且status为0
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);
}
}
}
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);
}
}
}
...全文
相关推荐
JS调用WebService示例
JavaScript调用WebService是一种跨语言的调用方式,允许使用JavaScript语言的前端页面能够调用后端基于C#等其他编程语言编写的WebService服务。
异步调用webservice返回responseXML为空的问题解决方法
"异步调用webservice返回responseXML为空的问题解决方法"在Web开发中,异步调用WebService是常见的做法,它能够提高应用程序的性能和用户体验,因为不会阻塞主线程等待响应
js调用webService组件
在调用WebService时,通常我们会使用POST或GET方法发送请求,并在响应中处理返回的数据。下面是一个基本的JS调用WebService的示例:```html<!
从ASP3.0和JavaScript调用WebService
本文主要探讨如何从ASP 3.0(Active Server Pages)和JavaScript这两种不同的编程环境调用WebService,以实现跨平台的数据交互。
Javascript调用Webservice的多种方法
在调用WebService时,XMLHttpRequest主要用来发送请求并接收返回的结果。


