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 ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.