I’m trying to make my jQuery code refreshing the div after deleting a post. My code looks like this:
$.post('/includes/classes/handler.php?do=postDelete', { postId: $postId },
function(data) {
$('.globalWrapper').fadeOut('slow').load(this).fadeIn('slow');
});
The script deletes perfectly, and fades in/out fine, but the window is not refreshed. I’ve seen that you need a file for the load() function. But isn’t there a way to refresh the div just? So that the PHP script I’m using to call posts is refreshed too?
UPDATE
HTML:
<div class='postHolder'>
<div class='postMain'>
<div class='postContent'>
</div><!-- postContent end -->
</div><!-- postMain end -->
<div id='postDelete'>Her is my delete div which i'm calling to delete a post.</div>
</div><!-- postHolder end -->
.postHolder is the div that has to be removed.
What do you mean refresh the div? You need to go grab what you want in the div and place it there using a get request. the div does not know where it came from. You could add an attribute to the div so you know where it came from and use that to refresh the div.
How about, instead of reloading the div, just do the
postdelete as you are doing and then just remove the post from the html. No need to actually go off and return a list of records to refresh the div.Use some jquery like this to remove the post.