我想用JavaScript来消费由CDYNE提供的Web气象服务。 这是我的代码:
<html>
<head>
<title>weather app</title>
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script language="JavaScript">
function CallService() {
var DTO = "{ 'ZIP': '85281' }";
$.ajax({
type: "POST",
url: "wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP",
data: JSON.stringify(DTO),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: true,
success: function (msg) {
alert(msg);
},
error: function (req, status, error) {
alert(req + "# " + status + "@ " + error);
},
complete: function (req, status) {
alert(req + "% " + status);
}
});
}
CallService();
</script>
</body>
</html>
当我运行的代码,它显示了警报,这意味着错误的翻译:#错误@和[目标对象]%错误:()函数和完整:函数,而不是成功:函数()被调用。 是否有任何人谁使用JavaScript来消费这样的天气服务? 任何帮助将不胜感激。