Difference between dataType jsonp and JSON

后端 未结 2 403
北荒
北荒 2020-12-14 18:26

I download Jquery UI autoload, looking to remote-jsonp.html. This is ajax function but i open console.. I can\'t see any request in my console...

What is difference

相关标签:
2条回答
  • 2020-12-14 18:31

    dataType: jsonp for cross-domain request, that means request to different domain and dataType: json for same domain-same origin request.

    Loads in a JSON block using JSONP. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true.

    Read about same origin policy

    Read more about jQuery AJAX

    0 讨论(0)
  • 2020-12-14 18:34

    With JSONP you shouldn't see an ajax request if that's what you're looking for. You should however see a request for the resource because JSONP is used for cross domain calls to pull in data from different domains.

    It returns your JSON data wrapped in a function name. jQuery handles the function name behind the scenes and passes the data into your success handler. The data is loaded by dynamically creating a script element with the src attribute pointing to the service being called and then attached to the browser's DOM. Then the browser makes a request to the resource and the web service responds with the callback function and data.

    0 讨论(0)
提交回复
热议问题