当使用HTTPS http来代替JSONP请求失败
我有一个客户端API,这使得使用JQuery的一个JSONP请求。一切正常
当这个API客户端不是使用SSL使用SSL时,却失败。
I have an API client which makes a JSONP request using JQuery. Everything works fine when this API client's not using SSL however fails when the SSL is used.
例如我有一个网址 http://apiclient.com 和我提出以下来自该域JSONP要求:
For example I have a URL http://apiclient.com and I am making following JSONP request from this domain:
$.ajax({
url: url,
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
success: function(data)
{
$.each(data.services, function(index, service) {
processService(service);
});
}
});
我看到在成功URL和回调函数指定的API主机作了适当的请求正确调用传递到得当格式的数据。
I see an appropriate request made to API host specified in the url and callback function in success is properly called with properly formatted data passed onto it.
然而,当我上面的API客户端的URL更改为 https://apiclient.com
没有请求在API主机观察。我没有看到错误日志中的任何一方。
However when I change above URL of the API client to https://apiclient.com, no request is observed at API host. I see no errors in either side of the logs.
请注意:唯一的区别就是 HTTP 为 HTTPS 在API客户端
Note: only difference is http to https on API client side.
你需要不同的处理JSONP请求使用https域时?
Do you need to handle JSONP request differently when using https domain?
感谢。
编辑:
这个问题只与Chrome的观察。它与Firefox和Safari。
但是我得到了火狐快速警告,询问我关于使未加密的请求,从
加密的网站。我允许它,从来没有见过的警告。
This issue is only observed with Chrome. It works with Firefox and Safari. However I got a quick warning on FireFox asking I am about to make unencrypted request from encrypted site. I allowed it and never saw the warning again.
找到了解决办法。问题是,jQuery和其他资源从非安全网站进口。解决方案是从https参考。
Found a solution. Problem was that JQuery and other resources were imported from non-secure sites. Solution was to reference from https.