更新jQuery的AJAX表单提交的问题 - 表单数据提交,但返回错误不是成功
从提琴手2:
我可以看到发送的数据。他们也出现在其他网站的数据库中。
从其他域/服务器的响应似乎不正确:
Response sent 38 bytes of Cookie data:
Set-Cookie: ARPT=YOLMQLS172.25.102.96CKMYK; path=/
This response did not contain a P3P Header.
是否可以安全使用,即使标头响应不正确,此实现继续吗?
我使用jquery validate plugin验证我的表单,然后jquery ajax将表单数据发布到外部网站(Marketo潜在客户平台)。
表单数据已成功提交到外部网站(Marketo)。我通过登录他们的网站验证了这一点,我可以看到我提交的测试表单帖子与所有的现场数据。
但是,我从ajax调用得到一个错误,而不是成功响应。
这是代码 - 任何想法?
$(feedbackForm).validate(
{
validClass: "success",
rules:
{
FirstName: { required: true },
LastName: { required: true },
Email:
{
required: true,
email: true
},
Question__c: { required: true }
},
messages:
{
FirstName: "Please enter your first name",
LastName: "Please enter your last name",
Email: "Please enter a valid email address",
Question__c: "Please enter your message"
},
submitHandler: function(form)
{
$.ajax(
{
type:"POST",
url: "http://app-k.marketo.com/index.php/leadCapture/save",
data: feedbackForm.serialize(),
success: function(response)
{
feedbackForm.find('.form_result').html(response.statusText);
alert('success');
},
error: function(response)
{
feedbackForm.find('.form_result').html(response.statusText);
alert("error");
}
});
return false;
}
http://app-k.marketo.com/index.php/leadCapture/save返回什么?在'error'函数中,如果你是console.log(response) - 那会返回什么?如果你要返回一个JSON数组,你可能只需要在你的AJAX函数中传递dataType:'json'。 –
Alert'$('#easycopyFeedbackForm')。serialize()'看看弹出了什么 – Norse
console.log(response)返回一堆东西,比如statusText =“error”。我不知道如何从对象中知道它是否返回json,但我尝试过dataType:'json'并且仍然是这样。 – IntricatePixels