【发布时间】:2012-06-06 13:28:13
【问题描述】:
首先喜欢这个资源 - 使用它并学习了几年。这是我的第一篇文章,因为我真的被困住了。我正在通过 ajax /jsonp 提交表单。如果我在本地运行此脚本 - 我会从域中收到带有成功代码的响应。如果我只是在浏览器中运行请求,它会给我回复成功代码。但是当我提交表单时,Firebug 在 RED 中给了我一个 200 OK,而服务器没有响应。 Safari 给我一个加载资源失败:取消。找不到太多关于错误的文档,所以我停了下来。我知道这对于你的专业人士来说可能非常恶心,但这是我的第一篇文章,所以任何指导都非常感谢!网上有两个例子:http://www.yourlifeportal.com/register.php,里面有reCaptcha的版本。 http://www.yourlifeportal.com/registerNew.php 没有 reCaptcha 以防添加验证码影响了我的代码。如果我只是需要一个耳光,也请告诉我。谢谢!
$.ajax({
url: 'http://myURLonaDifferentDomain',
data:jQuery(frm).serialize(),
type: 'POST',
dataType: 'jsonp',
jsonp: 'jsonp',
crossDomain: true,
error: function (xmlHttpRequest, textStatus, errorThrown) {
if(xmlHttpRequest.readyState == 0 || xmlHttpRequest.status == 0)
return; // it's not really an error
else
alert(xmlHttpRequest + ': ' + textStatus + ': ' + errorThrown);
},
success: function(jsonp) {
// Response handling code goes here
console.log(json.response.responseCode + ': ' + json.response.response + ': ' + json.response.responseDescription);
if (json.response.responseCode == 10527) {
document.getElementById('errorScreen').style.display='block';
$('#errorMsg').append('There was an error with your credit card transaction please go back and re-check your ');
}
if (json.response.responseDescription == "Registration was successful") {
window.location.replace("http://www.url.com/thankyou.php");
}
}
});
}
【问题讨论】: