I'm working on a task I need to display Post Content-Img-Title on click without reload the page.
I've coded Below code:
// code for ajax portfolio
jQuery('span#ajax_post_abc a').click(function(){
var portfolio_post_id= jQuery(this).attr('id');
var ajaxurl = jQuery('#ajax-script-url').val();
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
"action": "load-filter2",
port_post_id: portfolio_post_id
},
success: function(response) {
jQuery(".aajax-post-content").html(response); }
});
});
//New Ajax portfolio div
jQuery('#ajax_post_abc').click(function() {
jQuery(this).addClass('aajax-post-content');
});
And the resultant response in will be displayed in aajax-post-content
div.
But the problem is if I have n
posts and I click on n+1
, n+2
and so on it does not shows the output. But if I click on the very first Post n0
then it will show the output as I need.