请教大家一个问题:

我想通过JavaScript来获取一些数据,数据来源于这个网站:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx

用通过SOAP向这个网站发送POST请求来获取某个城市(比如,上海)的天气情况,我的核心代码是这样写的:

但是好像遇到了跨域的问题:

XMLHttpRequest cannot load http://www.webxml.com.cn/WebServices/WeatherWebService.asmx. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access. The response had HTTP status code 403.

(而且还发现xhr获取的status值等于0,不知道是不是代码哪里写错了)

我想请教的是,如何通过前端来解决这个问题?

2 收藏


直接登录
最新评论
  • Kenneth hired worker 2016/08/16

    I’m sorry. There is nothing you can do in the front end.

    They have to modify these web services.

    Add these three lines: