JSONP stands for JavaScript Object Notation with Padding. The response to a JSONP request is not parsed as JSON, but as JSON-formatted data. We Played with ‘plain’ JSON, right? Look here – Get your Twitter™s Tweet as RSS and JSON with New Twitter API.
The JavaScript Object Notation, JSON in short, is a compact data format for man and machine easily readable text form for the purpose of data exchange between applications. Any valid JSON document is a valid JavaScript, can be interpreted by eval ()
function. Due to small variations in the amount of allowable Unicode characters, however it is possible to generate JSON objects that are not accepted by a standards-compliant JavaScript interpreter. Apart from this JSON works regardless of the programming language. Parsers exist in virtually all widely used languages. JSON was originally developed by Douglas Crockford. Currently it is specified by two competing standards, the RFC 7159 by Douglas Crockford and ECMA-404.
But, we are not talking about JSON, but JSONP. JSONP (JSON with Padding ) allows transmission of (JSON) data on domain boundaries. Usually Ajax data queries are sent to the server via the XMLHttpRequest object of a web browser. The problem of same-origin policy can be circumvented by JSONP.
---
The Basic Idea about JSONP Script Tags
The src attribute of a script
element can possibly specify arbitrary URLs. For this
attribute, the same-origin policy does not apply. So, it is possible to specify a URL in a different domain, the example returns JSON data. This script would have no effect. The server packaged this JSON data to the client to process, as a parameter to a JavaScript function that is already defined in the web browser. The name of this function is the server via a querystring
communicated to the URL; for example:
This was the example of Padding. This JSON data could be dynamically generated, according to the query parameters passed in the URL. For each JSONP call their own is
Search this website…