getJSON()
is simply shorthand for the ajax()
function with the dataType:'json'
set. The ajax()
function will let you customize a lot about the request.
$.ajax({
url: "https://stackoverflow.com/questions/4116992/MyArray.json",
async: false,
dataType: 'json',
success: function (response) {
// do stuff with response.
}
});
You still use a callback with async:false
but it fires before it execution continues on from the ajax call.