Skip to content

Instantly share code, notes, and snippets.

@filipkral
Created May 30, 2014 15:36
Show Gist options
  • Save filipkral/45b49cad4d23fb211632 to your computer and use it in GitHub Desktop.
Save filipkral/45b49cad4d23fb211632 to your computer and use it in GitHub Desktop.
basic jQuery get, post, ajax
// get
function yay(a,b,c){ console.log(['yay', a, b, c]); }
function nay(a,b,c){ console.log(['nay', a, b, c]); }
$.get({url: 'http://foo.bar/spam?eggs=1', dataType:'jsonp'}).done( yay ).fail( nay );
$.post("http://foo.bar/spam", {eggs: 1} ).done( yay ).fail( nay );
var jqxhr = $.ajax( {url:"http://foo.bar/spam", data: {}, method: 'GET', dataType: 'jsonp'}).done( yay ).fail( nay ).always(function() { console.log( "always" ); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment