Created
January 4, 2012 07:20
-
-
Save deadlyhifi/1558945 to your computer and use it in GitHub Desktop.
Response to http://deadlyhifi.com/2011/12/loading-frontend-ajax-content-in-wordpress/#comment-399457380
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
function dhf_loadme_ajax() { | |
if ( isset($_POST['page_id']) ) : | |
file_get_contents(get_permalink( $_POST['page_id'] )); | |
endif; | |
die(); | |
} |
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
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