Dave's Brain

Browse - 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); } }); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.