Created
May 19, 2013 17:33
-
-
Save brettsnippets/5608365 to your computer and use it in GitHub Desktop.
JavaScript: jQuery Ajax Call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajaxSetup({cache:false}); | |
$("a.linkContainingUrl").click(function(){ | |
var post_url = $(this).attr('href'); | |
var post = $('#post-here'); | |
post.html('<img src="../img/ajax-loader.gif" />'); /* shows ajax loader until content is loaded */ | |
post.load(post_url + ' #pull-this-content'); | |
/* within the #post-here div, this will load in the post url from the a:link being clicked, | |
the #post- is pulling in the div that contains the content we want to bring in, instead of pulling | |
in the entire page. This could easily be anything like, #pull-this-content, it doesn't have to contain the post id */ | |
return false; // this just tells the browser that the link shouldn't behave like a typical link | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment