bhylu.com

Advertisements

JS JSONP

JSONP loads a remote script that calls a callback. It is executable third-party code rather than ordinary JSON, so prefer a CORS-enabled data API.

Where to run this

Use a local browser project for this example. It needs browser permissions, additional files, a server endpoint, or a library as described below. The restricted playground cannot provide those dependencies.

A practical example

JavaScript

// Historical response shape; do not load arbitrary JSONP sources.
function receiveSession(data) {
  console.log(data.title);
}
receiveSession({title: "Repair club"});

What happens

The local demonstration shows the callback contract without loading remote code.