I have found a useful article that also explains the topic quite clearly and easy language. Link is JSONP
Some of the worth noting points are:
- JSONP pre-dates CORS.
- It is a pseudo-standard way to retreive data from a different domain,
- It has limited CORS features (only GET method)
Working is as follows:
<script src="url?callback=function_name">
is included in the html code
- When step 1 gets executed it sens a function with the same function name (as given in the url parameter) as a response.
- If the function with the given name exists in the code, it will be executed with the data, if any, returned as an argument to that function.