0

我正在为我的登录表单使用 jQuery/AJAX。以下脚本适用于最新版本的 Firefox、Opera 和 Google Chrome,但在 bot IE6 和 IE9 上失败。无论我输入的密码是正确的还是错误的,都会使用“readystate=0, status=0, statusText="Error: Invalid argument." 调用我的错误函数。

$(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;
    });
  });
});
4

0 回答 0