JSONP request fails when https is used instead of http

后端 未结 3 615
挽巷
挽巷 2021-01-03 21:50

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 e

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 22:36

    There shouldn't be any different in JSONP request for http and https.

    Try us .getJSON instead:

    $.getJSON(url, function(data) {
      $.each(data.services, function(index, service) {
            processService(service);
        });
    });
    

    Using jQuery.ajax() will cause cross-browser issue but not the case with jQuery.getJSON() Look at jQuery site for more info: http://api.jquery.com/jQuery.getJSON/

    There's similar post with this issue: JSONP To Acquire JSON From HTTPS Protocol with JQuery

提交回复
热议问题