JSONP works by adding the required URL to a HTML script tag. This is typically done by manipulating the HTML DOM using a technique known as script element injection. The script tag is allowed to access files from other domains.
The browser executes the response from the server. The callback function is defined on the page that makes the Ajax call.