简体   繁体   English

javascript中的ajax调用存在HTTPS问题

[英]HTTPS issue with ajax call in javascript

I am calling a webservice using ajax call(javascript) to return json.It is working fine.But when i changed my site to HTTPS it is not working.What will be the reason? 我正在使用ajax调用(javascript)调用Web服务以返回json。它工作正常。但是当我将站点更改为HTTPS时,它不起作用,这是什么原因?

function GetReportguid1, callback) { 
 $.ajax({
       type: "POST",
       url: "/demo/Datapage.aspx/GetData",
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       data: JSON.stringify({
           guiddemo: guid1           
       }),
       success: function (results) {          
           callback(results);
       },
       error: AjaxFailed
   });


};

Add the Access-Control-Allow-Origin header from the server 从服务器添加Access-Control-Allow-Origin标头

Access-Control-Allow-Origin: https://www.yoursite.com 访问控制允许来源: https://www.yoursite.comhttps://www.yoursite.com

http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing

And try use JSONP instead. 并尝试使用JSONP代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM