How do you make an Ajax call in jQuery?

{ "status": "ok", "items": 3 }
<p>Page</p>
$.ajax({ url: 'data.json', dataType: 'json' })
  .done(function (res) { console.log('Status: ' + res.status + ', items: ' + res.items); })
  .fail(function () { console.log('Request failed'); });
Console output

Status: ok, items: 3

See jQuery Ajax.


Learn more about the similar topics:
Tutorials
jQuery load() Method
jQuery Ajax: ajax(), get(), post() and getJSON()
jQuery Deferred, Promises and $.when()
Exercises & Assignments
Write jQuery code to load JSON data with Ajax and show it in a list
Write jQuery code to submit a form with Ajax
Interview Questions & Answers
How do you make an Ajax call in jQuery?
What is the difference between $.get(), $.post() and $.ajax() in jQuery?
What are Deferred objects and promises in jQuery?
How do you handle Ajax errors in jQuery?