javascript - 跨域时出现了“Internal Server Error”问题

查看:220
本文介绍了javascript - 跨域时出现了“Internal Server Error”问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

  1. 想用这个网站(http://www.webxml.com.cn/zh_c...)上的xml数据,写一个天气预报的网页

  2. 用的jq的ajax方法,使用了这个cors(https://crossorigin.me/)跨域网址

  3. 运行代码后出现的错误

源代码

<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,没问题就跟后端协商下吧。

这篇关于javascript - 跨域时出现了“Internal Server Error”问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆