views:

31

answers:

1

can someone show me how to make a jquery ajax completion event.

$("#submit_js").click(function() {
    $.post(
      "user_submit.php", 
      {comment: $("#comment").val(), aid: imgnum}, 
      function(data){
        /*alert(data);*/
      });
});

when this POST request completes successfully, I want to show the message in a specific div instead of its earlier contents:

Your comment : $('#comment').val() was submitted successfully.

//I want to display the comment.

+1  A: 

Put this inside your "on complete" callback function:

$( 'selector for your DIV' ).html ( 'your message' );
Jan Hančič
how to make the on complete callback function? sorry n00b here.
amit
function(data){/*alert(data);*/} is your callback. put the my code in there and it will be executed when the AJAX call returns sucsesfully.
Jan Hančič