Refresh a div with ajax response
So i have a comments box with a form (textbox and submit). This gets
validated and then sent to the php page via ajax.
If all okay, the response is set and the page continues.
I want however the div to refresh itself so that you can see the new comment.
I dont want anything complicated like appending etc just simply to reload
the div (data is pulled from database).
I have used this in the past but it doesnt work:
$('#divid').load('page.php #divid'),
any idea how i can convert this:
if (check == true) {
$.ajax({
type: "POST",
url: "process/addcomment.php",
data: $targetForm.serialize(),
dataType: "json",
success: function(response){
if (response.databaseSuccess)
$comment.after('<div class="error">Comment Added</div>');
else
$ckEditor.after('<div class="error">Something went wrong!</div>');
}
});
}
return false;
});
});
To refresh the div once the success gets responded?
Thanks.
No comments:
Post a Comment