简体   繁体   中英

AJAX call from function won't work

var usernameInfo= $('#usernameInfo');
var ele= $('#username');
var username= ele.val();
if(username.length >=6 || username.length <=32)
{
  usernameInfo.removeClass('error').addClass('correct').html('<img src="loader.gif" align="absmiddle" />&nbsp;Checking availability...');
  ele.removeClass('wrong').addClass('normal');
  $.ajax({
    type: "POST",
    url: "ajax_check_username.php",
    data: "username=" + username,
    succes: function (server_response) {
      usernameInfo.ajaxComplete(function(event, request){
        if(server_response == '1')                                
        {
          jVal.errors= true;
          usernameInfo.removeClass('correct').addClass('error').html('<img src="not_available.png" align="absmiddle" /> Not Available').show();
          ele.removeClass('normal').addClass('wrong');
        }
        else if(server_response == '0')
        {
          usernameInfo.removeClass('error').addClass('correct').html('<img src="available.png" align="absmiddle" /> Available').show();
          ele.removeClass('wrong').addclass('normal');
        }
      });
    }
  });     
}

The thing is that i have used this AJAX call from another script that it works with working .php file (tested and working), but now it just won't... any help would be good. Thanks

          succes: function (server_response) {

您拼错了成功

Its:

success: function(resp){ .... }
//you have spelling mistake there

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM