In JavaScript what are the differences between JSON and JSONP for cross domain?

In case of cross-domain, we are not allowed to get JSON response using AJAX request. This restriction is for same-origin policy. But a script tag can load JSON from cross-domain. So, instead of AJAX call if we call the cross-domain using script tag then we will be able to load the desired JSON.

When loading JSON it is difficult to know when the JSON was loaded and the processing of that JSON is not easy.

To solve this issue the JSONP came is place. JSONP is the padded JSON. This means we are allowed to pass a call back so that when the JSON loads using script tag we have control.

Share