Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IS JSONP classified as AJAX?

Is JSONP classfied as AJAX?

I am confused as i understood that the XHR is required to be used for the asynchronous communication but when i look at the jQuery code for JSONP it is "wrapped in an AJAX call

jQuery AJAX

if JSONP is not classified as AJAX then why have jQuery bundled it as an AJAX function or am i missing something here?

like image 301
android_baby Avatar asked Jan 11 '12 23:01

android_baby


People also ask

What is JSONP in AJAX?

JSONP stands for JSON with Padding. Requesting a file from another domain can cause problems, due to cross-domain policy. Requesting an external script from another domain does not have this problem. JSONP uses this advantage, and request files using the script tag instead of the XMLHttpRequest object.

Can JSONP be used with AJAX?

JSONP has nothing to do with Ajax, since it does not use XMLHttpRequest.

What is JSONP format?

“JavaScript with Padding” (JSONP) Also called “JSON with Padding”, it is a technique for fooling a web browser into performing cross-origin requests using a special <script> tag that uses the src attribute to make a special API request.

Is JSONP deprecated?

JSONP is vulnerable to the data source replacing the innocuous function call with malicious code, which is why it has been superseded by cross-origin resource sharing (available since 2009) in modern applications.


1 Answers

If you'd strictly say that AJAX means "asynchronous communication between JavaScript and a Server using XML format", then only a few techniques called "Ajax" today would meet that definition, as even many "XML-HTTP-Requests" do not transport XML data.

So the JSONP technique is just one of the known asynchronous communication methods, and jQuery wanted to bundle all of them into one function - named with the most common term "ajax".

However, the term "ajax" is closely linked to the XMLHTTPRequest interface, which is limited by the same-origin-policy. While this one does not apply to JSONP, which uses <script> elements, JSONP is limited to GET-requests and needs a special serverside infrastructure.

like image 57
Bergi Avatar answered Sep 21 '22 02:09

Bergi