JSONP

Use XMLHttpRequest when your HTML and JavaScript are hosted on the same machine as your data.

Use JSONP when you need to access data hosted by a web service on a remote server (assuming that web service supports JSONP). A web service is a web API that is accessed by HTTP.

ƒƒJSONP is a method of retrieving data by using the <script> element.

ƒƒJSONP is JSON data wrapped in JavaScript; typically, a function call.

The function call that wraps the JSON data in JSONP is referred to as a “callback.”


script injection

force the browser to make the request


watch out for the dreaded browser cache

var url += "&random=" + (new Date()).getTime();












你可能感兴趣的:(JSONP)