首先爱这个资源 - 一直在使用它和学习一两年了。这是我的第一篇文章,因为我真的被卡住了。我通过ajax/jsonp提交表单。如果我在本地运行这个脚本 - 我用成功代码从域中获得回应。如果我只是在浏览器中运行请求,它会给我回应成功代码。但是当我提交表单时--Firebug给我一个红色的200 OK,服务器没有响应。 Safari让我无法加载资源:取消。无法找到关于错误的很多文档,所以我停下了脚步。我知道这可能是非常令人厌恶的专业人士阅读,但这是我的第一篇文章,所以任何指导表示赞赏!在线有两个示例:http://www.yourlifeportal.com/register.php其中包含reCaptcha的版本。 http://www.yourlifeportal.com/registerNew.php没有reCaptcha只是添加了验证码,影响了我的代码。如果我只是需要脸上的一点点,让我也知道。谢谢!ajax jsonp请求 - 没有回复
$.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");
}
}
});
}
我以为jsonP是跨域问题的解决方案吗? –
这是Firebug为响应标题显示的内容。我缺少的东西吗?日期\t孙,2011年8月21日7点15分五十秒GMT 服务器\t的Apache/2.2.8(CentOS的) 内容语言\t的en-US 的Content-Length 连接\t接近 内容 - 键入\t application/x-javascript; charset = UTF-8 –
是的,没有CORS头文件(它看起来像'Access-Control-Allow-Origin')。你可以看到请求是否看起来像一个JSOP请求(在GET中会有一个参数,如'jsonp = xyz'),如果响应是正确的(它将以'xyz(...')开始) – Malvolio