O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a jQuery .get() AJAX Request to Handle JSON Data

$.get("getJSONData.php", myHandler); function myHandler(data){   var responseValue = data.value; }

Using jQuery to get JSON data from the server is extremely easy. Just call the .get(url, handler(data)) method, pass in the url to the server location, and specify a handler to handle the data. For example:

$.get("getJSONData.php", myHandler);

The JSON data returned by the response will be a JSON object that is passed as the first argument to the handler function. You can access the data using dot syntax; for example:

function myHandler(data){   var responseValue = data.value; }

The best way to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required