XMLHttpRequest cannot load https:\rippleapi.herokuapp.com\xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//www.my-domain.com/WebService.asmx/selectData. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http:\localhost:4400’ is therefore not allowed access. The response had HTTP status code 503.
>在服务器端(web.config)提供了cors:
< system.webServer>
< defaultDocument>
<文件>
< clear />
< add value =“index.aspx”/>
< add value =“WebService.asmx”/>
< /文件>
< / defaultDocument>
< httpProtocol>
< customHeaders>
< add name =“Access-Control-Allow-Origin”value =“*”/>
< add name =“Access-Control-Allow-Headers”value =“Content-Type”/>
< / customHeaders>
< / httpProtocol>
< /system.webServer\u0026gt;
<&的System.Web GT;
< WEBSERVICES>
<协议>
< add name =“HttpGet”/>
< add name =“HttpPost”/>
< /协议>
< / WEBSERVICES>
< customErrors mode =“RemoteOnly”defaultRedirect =“mycustompage.htm”/>
< /system.web\u0026gt;
< system.serviceModel>
>我的AJAX方法:
$就({
键入: “POST”,
crossDomain:true,
网址:“http://www.my-domain.com/WebService.asmx/selectData”,
data:JSON.stringify(campaignData),
contentType:“application / json; charset = utf-8”,
dataType:“json”,
成功:功能(msg)
{
var response = msg.d;
var resultLoop = $.parseJSON(response);
的console.log(响应)
},
错误:函数(xhr,ajaxOptions,thrownError)
{
$.mobile.loading( ‘隐藏’);
alert(“status:”xhr.status“thrownError:”thrownError“ajaxOption:”ajaxOptions);
}
});
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。