2013-12-10 69 views
0

我更新jquery到一箇舊版本的文件,有一些新的功能添加更新的版本。現在,jquery ajax發佈已停止工作。我試圖改變成功,但這並沒有解決問題。Ajax請求與jQuery的舊版本不是新的

// check email in database 
$("#email_address").change(function() //this function needs tidying up! 
{ //if theres a change in the email textbox 

    var email_address = $("#email_address").val(); //Get the value in the username textbox 
    if (email_address.length > 3) //if the lenght greater than 3 characters 
    { 
     $("#availability_status").html('<img src="../img/loader.gif" align="absmiddle"> Checking this email is not already registered<br />'); //Add a loading image in the span id="availability_status" 

     $.ajax({ //Make the Ajax Request 
      type: "POST", 
      url: "../ajax_check_email.php", //file name 
      data: "email_address=" + email_address, //data 
      success: function (server_response) { 

       $("#availability_status").ajaxComplete(function (event, request) { 

        if (server_response == '0') //if ajax_check_email.php return value "0" 
        { 
         $("#availability_status").css("display", "none"); 
        } else if (server_response == '1') //if it returns "1" 
        { 
         $("#availability_status").css("display", "inline"); 
         $("#availability_status").html('<font color="red">This email address is already registered in our database. </font>'); 
        } 

       }); 
      } 

     }); 

    } 

    return false; 
}); 

回答

1

我猜那就是:

http://api.jquery.com/ajaxComplete/

「在jQuery 1.8中,.ajaxComplete()方法只應附於文件。」

但是,我不確定爲什麼會出現這種情況。你應該能夠完全刪除ajaxComplete部分:

success: function (server_response) { 

    if (server_response == '0') //if ajax_check_email.php return value "0" 
    { 
     $("#availability_status").css("display", "none"); 
    } else if (server_response == '1') //if it returns "1" 
    { 
     $("#availability_status").css("display", "inline"); 
     $("#availability_status").html('<font color="red">This email address is already registered in our database. </font>'); 
    } 

} 
+0

我完全刪除了.ajaxComplete(),它工作。謝謝。 – JakeKempo

0

應該足夠:

$(document).ajaxComplete(
0

在jQuery 1.8中,.ajaxComplete()方法只應附於文件,如:

$(document).ajaxComplete(function() { 
    // do something on complete 
}); 

documentation

您的AJAX請求中有一個ajaxComplete()方法。你不能使用回調之類的complete()回調嗎?

$.ajax({ 
    type: "POST", 
    url: "../ajax_check_email.php", //file name 
    data: "email_address=" + email_address, //data 
    success: function() { 
     // do something 
    }, 
    complete: function() { 
     // do something 
    } 
});