tags:

views:

40

answers:

1

I have a list of posts that is loaded onto my page using ajax like so:

var fm = <?php echo $from_user ;?>;

$("#microblogposts").load("posts.php", {from_user: fm}, function(){
});

Within this list of posts I have a function to delete posts from the list:

    //START POST DELETE FUNCTION    
$("form#deletepost").submit(function() {

// we want to store the values from the form input box, then send via ajax below
var deleteid = $('#deleteid').attr('value');

//START AJAX    
$.ajax({
    type : "POST",
    url: "process.php",
    data: {deleteid : deleteid},
    error: function(){ 
    alert("Mesage could not be posted at this time. Please try again.");
    },
    success: function(){ 

            $("#microblogposts").load("posts.php", {from_user: fm}, function(){
            //alert("posts have been loaded");
            });

            $("#latestpost").load("latestpost.php", {from_user: fm}, function(){
            //alert("latest posts have been loaded");
            });

    }
    //END SUCCESS FUNCTION
});
return false;
//END AJAX  

}); 
//END POST DELETE FUNCTION  

I want the code to refresh some elements in the DOM when the AJAX is successful but it doesn't work, is there anyway this can be done???

+1  A: 

Thanks for the help jigfox. The problem was with the variables, they where both empty hence the content not loading.