Programming Tips - How can I use Ajax with jQuery?

Date: 2017sep25
Language: javaScript
Library: jQuery

Q.  How can I use Ajax with jQuery?

A.  I do not use the post() or get() methods because they don't
have an error callback.  Its not so hard to use ajax().

function getSomeInfo() { $.ajax({ type: 'get', // We are doing a GET url: 'get_some_info.php', // You make this dataType: 'json', // Its returning JSON cache: false, // Don't cache the result success: function(data, textStatus, jqXHR) { // Do something with data $('#status').html('done'); }, error: function(data, textStatus, jqXHR) { $('#status').html(textStatus); } }); }