|
Ajax,or more properly,AJAX,stands for Asynchronous Javascript And Xml. Technically it refers to any asynchronous request made by the browser (anything that uses an JSON is a data encoding format. The name itself is an acronym for "JavaScript Object Notation". JSON-formatted data looks like: {"key": "value1", "key2": {"number": 1, "array": [0, 1, 2]}} JSON data may be fetched by an AJAX request,though it is quite commonly used in other contexts as a lightweight,extensible,and easy-to-parse data exchange format. JSONP is simply JSON-formatted data wrapped in a callback function. The "P" stands for "with Padding",which is kind of stupid unless you like to think of function calls as "padding". In any case,JSONP data will look like: someFunction({"key": "value1", 2]}}); As such,JSONP is really just a JavaScript snippet,and unlike JSON is not used outside of the context of JavaScript,browsers (or other JavaScript-capable clients),and AJAX requests. The reason for using JSONP is that it allows the same-origin policy to be subverted. A script that was sourced in from site X cannot make a direct request to site Y if site Y is on a different domain from site X. But if site Y's server can send JSONP-formatted responses,then the script from site X can add a new Note that JSONP data is not (typically) requested using an REST is simply the formal spec/description of how HTTP actually works/is intended to be used. If you understand the concept of a URL being used to request a corresponding resource from a server and the difference between
///未完待续.......... |