I am writing a contact form using jQuery AJAX POST and PHP. The form works well and sends the email. What I want to know is how to get the return values for error and success on the same page where the contact form is rather than having the message go to another page. I created a DIV called statusBox, and I would like all the messages printed there. Below is the fragment from the jQuery side. What do I need to do on the PHP side to get the values back?
var data_string = $('form#contactform').serialize();
$.ajax({
type: "POST",
url: "slidinglabelsFormMail.php",
data: data_string,
success: function(response) {
$('#statusBox').html(response);
$('#statusBox').html('<div id="success"></div>');
$('#statusBox').html('<h3>Success</h3><p>Your email has been sent.</p>');
},//end success function
error: function(response){
$('#statusBox').html(response);
}
}) //end ajax call
return false;