Reputation: 489
I have this contact form on my website, the things i want to do is that since i have the contact button on all pages, when the user clicks the contact button, the contact form pops out.That has been achieved. Then after the user clicks the submit button on the contact form, instead of taking the user to the result page, i want a result div to just popup on that same current page the user is on.How can I go about this?
Upvotes: 1
Views: 585
Reputation: 2382
The best way is to use this pattern:
$.ajax({
type: "POST",
url: "test.php",
data: "do=" + do,
success: function(dta){
$("#alert").html("Success");
}
});
Upvotes: 3
Reputation: 23770
Use http://jquery.malsup.com/form/#ajaxForm to ajaxify the form, and in the callback set innerHTML of your div accordingly.
$('#myForm').ajaxForm(function() {
$('#someDiv').html("Success!");
});
Upvotes: 1