提交以下 $.ajax,它确实正在执行,但无提示地失败,没有任何错误。IE9 开发工具不会弹出错误,提琴手显示没有流量。
我可以确认代码确实执行了,因为屏幕上确实出现了“处理”位。然而,其余的似乎只是失败了。我不是在做 x 域。
$('.signupMsg').html("<img src='/assets/img/load-black.gif' /> Processing...");
var data = $('#emailForm').serialize();
$.ajax({
url: 'https://example.com/proxy/emaillist',
type: 'POST',
data: data,
statusCode: {
200: function(msg) {
$('.signupBlock').html(" <br><strong>Thank you!</strong><br>You will be hearing from us soon.");
$('#emailForm').remove();
},
500: function(msg) {
$('.signupBlock').html(" <br><strong>Something went wrong.</strong><br>Sorry about that, please <a href='/'>refresh</a> and try again.");
$('#emailForm').remove();
},
404: function(msg) {
$('.signupBlock').html(" <br><strong>Something went wrong.</strong><br>Sorry about that, please <a href='/'>refresh</a> and try again.");
$('#emailForm').remove();
},
503: function(msg) {
$('.signupBlock').html(" <br><strong>Server temporarily down.</strong><br>Sorry about that, please <a href='/'>refresh</a> and try again.");
$('#emailForm').remove();
},
400: function(msg) {
$('.signupMsg').html("<span style='color:red'>Email validation failed, please try again.</span>");
}
}
});
使用 jQ 1.7.2。该代码在 Google Chrome 中执行良好,但在 IE7-9 和 FF 中失败。旧浏览器不支持 statusCode 吗?
或者我应该切换到 SuperAgent 以获得代码响应支持?http://visionmedia.github.com/superagent/