想用这个网站(“http://www.webxml.com.cn/zh_c...”)上的xml数据,写一个天气预报的网页
用的jq的ajax方法,使用了这个cors(“https://crossorigin.me/”)跨域网址
运行代码后出现的错误
源代码
<input type="button" id="testing" value="测试" />
$('#testing').click(function () {
var cors="https://crossorigin.me/";
var urlWeather="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather?theCityCode=486&theUserID=";
$.ajax({
url:cors+urlWeather+"",
type:"GET",
success:function (text,status,xhr) {
console.log(text+'\n'+status+'\n'+xhr);
},
error:function (xhr,status,error) {
console.log(xhr+'\n'+status+'\n'+error);
console.log(xhr);
},
});
});
这应该是一个后台错误,当然不排除是因为前端调用参数不正确引发的(虽然理论上不这种情况不应该引发后端直接抛出异常),检查一下 API,没问题就跟后端协商下吧。