Skip to content

Instantly share code, notes, and snippets.

@deadlyhifi
Created January 4, 2012 07:20
Show Gist options
  • Save deadlyhifi/1558945 to your computer and use it in GitHub Desktop.
Save deadlyhifi/1558945 to your computer and use it in GitHub Desktop.
function dhf_loadme_ajax() {
if ( isset($_POST['page_id']) ) :
file_get_contents(get_permalink( $_POST['page_id'] ));
endif;
die();
}
jQuery(document).ready( function($) {
$("a.getviews").click( function() {
var request = $(this).parent();
/* only fetch results once */
$(this).unbind('click').bind('click', function(){return false;});
// replace button with loader
$(td).html('<span class="loader"></span>');
$.ajax({
type: 'POST',
url: ajaxurl,
data: { action: "dhf_loadme_ajax", page_id: request.attr("id") },
success: function(response) {
request.html(response);
return false;
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment