I am getting Error in submitting the form using AJAX and Jquery, following is the code i’m using to submit the form.
function formControl() {
$('form#form_contact').submit(function(){
if (verifyErrors()) {
action = $(this).attr('action');
mesagetosend = $(this).serialize();
$.ajax({
type: "POST",
url: 'mailscript/smtpmail.php',
data: mesagetosend,
dataType : "html",
timeout:10000,
error: function(msg) {
alert("Error:="+msg);
onerrormsg(msg);
},
success: function(msg){
alert("Success:="+msg);
onsuccessmsg(msg);
}
});
}
return false;
});
}
in alert i’m getting "Error:=[object XMLHttpRequest]"
do anyone have any idea, why it returns error???
That’s becuase you’re printing the whole object. The error function actually returns three arguments:
Do it like this instead: