现在,我想使用来自http://www.webservicex.net/globalweather.asmx的服务来通过javascript获取天气。我试试这段代码:
var wsUrl = "http://www.webservicex.net/globalweather.asmx?op=GetWeather";
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
success: processSuccess,
error: processError
});
});
});
function processSuccess(data, status, req) {
if (status == "success")
$("#response").text($(req.responseXML).find("GetWeatherResult").text());
}
function processError(data, status, req) {
alert(req.responseText + " " + status);
// alert("Error");
}