ajax如何实现WeatherWebService
来源:百度知道 编辑:UC知道 时间:2024/09/27 23:22:37
RT
只用javascript实现WeatherWebService的xml服务时
xmlHttp.open("GET",url);中的url要是xml的地址,而WeatherWebService提供的是这样的地址:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=58259
如果用上面的地址就会使xmlHttp.responseXML为空 就没法继续
求高手解答
能否只用javascript获取第三方的xml服务?
只用javascript实现WeatherWebService的xml服务时
xmlHttp.open("GET",url);中的url要是xml的地址,而WeatherWebService提供的是这样的地址:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=58259
如果用上面的地址就会使xmlHttp.responseXML为空 就没法继续
求高手解答
能否只用javascript获取第三方的xml服务?
RequestByPost(method,variable,value,url,_Namespace)
method:webservice的方法名
variable:webservice的方法的变量名数组
value:webservice的方法的变量的值的数组
url:请求的地址(asmx文件地址)
_Namespace:webservice的命名空间
<script language="javascript" type="text/javascript">
// <!CDATA[
//define
var xmlhttp;
var value=new Array();
var variable=new Array();
//Show Response MSG.
function handleStateChange()
{
var h=document.getElementById("Label1");
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
alert(xmlhttp.responseText);
h.innerHTML=xmlhttp.responseText;
//h.innerHTML=xmlhttp.responseXML;
}
else if(xmlhttp.status==404)
{
h.innerHTML="<br>找不到请求的服务器资源!";
}
}
else if(xmlhttp.readyState==0)
{