Search code examples
javascriptajaxjsonp

What is the difference between an JSONP request and AJAX request?


I've been digging for an answer to the above solution, but I did not found something interesting. Can you guys please explain it in clear words??


Solution

  • Ajax is a generic term that means "Making an HTTP request and processing its response, from JavaScript, without leaving the page".

    JSONP is a specific means of making an Ajax request that is performed by adding a <script> element that loads an external JavaScript program that does nothing except call a specified function with some data as the first argument. It is a hack to get around the Same Origin Policy. (It is obsolete in the face of CORS which provides a much safer, and more refined, means to do the same thing).