我正在使用jQuery / AJAX登录表单。以下脚本适用于最新版本的Firefox,Opera和Google Chrome,但在bot IE6和IE9上失败。无论我输入正确的密码还是错误的密码,我的错误函数都会调用“readystate = 0,status = 0,statusText =”错误:参数无效。“。
$(function() {
$(document).ready(function(){
$("form").submit(function(){
var thistarget = this.target;
jQuery.ajax({
data: $(this).serialize(),
url: this.action,
type: this.method,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
error: function(xhr, textStatus, errorThrown) {
if (typeof xhr.responseText !== "undefined") {
$('strong.message').text(xhr.responseText);
} else {
$('strong.message').text("Bad username and/or password");
}
$('div.alert').show();
},
success: function(response) {
document.location.href='/';
}
});
return false;
});
});
});