One notable problem in the javascript is you are defining dataString
prior to defining the variables it contains like email
.
ALso the dataString
is not valid form encoding. It should look like 'email=foo@foo.com&name=foo'
once it is compiled. It can't have html in it
It is simpler passing an object to data
of $.ajax
and let jQuery compile it for you or use $('#formId').serialize()
to gather all the data in a whole form
Try this instead:
var data = {
name: $("input#name").val(),
email: $("input#email").val(),
phone: $("input#phone").val()
}
var $dialog=$(this)
$.ajax({
type: "POST",
url: "mailer.php",
data: data,
success: function () {
$dialog.dialog("close");
}
});