JSONP request fails when https is used instead of http

datauser picture datauser · Jan 3, 2013 · Viewed 16.4k times · Source

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.

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);
        });
    }
});

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.

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.

Note: only difference is http to https on API client side.

Do you need to handle JSONP request differently when using https domain?

Thanks.

Edit: 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.

Answer

datauser picture datauser · Jan 8, 2013

Found a solution. Problem was that JQuery and other resources were imported from non-secure sites. Solution was to reference from https.