Перенос кода AJAX двухлетней давности на текущую версию jQuery. Почему это терпит неудачу?Jquery

Программирование на jquery
Anonymous
Перенос кода AJAX двухлетней давности на текущую версию jQuery. Почему это терпит неудачу?

Сообщение Anonymous »

Я написал приведенную ниже функцию чуть более двух лет назад, когда текущая версия jQuery была 3.6. В те времена это работало отлично.
Я возвращаюсь к этому старому коду, перепрофилирую его и переношу в современную эпоху с помощью jQuery 3.7.1.
Когда функция выполняется, я получаю ошибку TypeError, показанную в конце этого сообщения в консоли браузера.
Может ли кто-нибудь сказать мне, что здесь не так?
Может ли кто-нибудь сказать мне, что здесь не так?
p>
Спасибо!

/*
Performs an AJAX username lookup. Used to verify whether a username has already been claimed by a previous user
*/
var jqxhr = $.ajax( { url : '/_globals/ajax/lookup-username.php',
dataType : 'json',
async : false,
method : 'POST',
data : { fname : firstName,
mi : initial,
lname : lastName,
generation : generation,
username : userName
}
} )

.done( function( resultObject ) { // handle a successful lookup
console.log( 'Username lookup success' );
userNameExists = resultObject.exists;
}) // end .done

.fail( function() { // handle a failed lookup
console.log( 'Username lookup failure' );
}) // end .fail

.complete( function() { // handle a completed lookup
console.log( 'Username lookup complete' );
}); // end .complete
}; // end function lookupUserName()


[Error] TypeError: $.ajax( { url : '/_globals/ajax/lookup-username.php',
dataType : 'json',
async : false,
method : 'POST',
data : { fname : firstName,
mi : initial,
lname : lastName,
generation : generation,
username : userName
}
} )

.done( function( resultObject ) { // handle a successful lookup
console.log( 'Username lookup success' );
userNameExists = resultObject.exists;
}) // end .done

.fail( function() { // handle a failed lookup
console.log( 'Username lookup failure' );
}) // end .fail

.complete is not a function. (In '$.ajax( { url : '/_globals/ajax/lookup-username.php',
dataType : 'json',
async : false,
method : 'POST',
data : { fname : firstName,
mi : initial,
lname : lastName,
generation : generation,
username : userName
}
} )

.done( function( resultObject ) { // handle a successful lookup
console.log( 'Username lookup success' );
userNameExists = resultObject.exists;
}) // end .done

.fail( function() { // handle a failed lookup
console.log( 'Username lookup failure' );
}) // end .fail

.complete( function() { // handle a completed lookup
console.log( 'Username lookup complete' );
})', '$.ajax( { url : '/_globals/ajax/lookup-username.php',
dataType : 'json',
async : false,
method : 'POST',
data : { fname : firstName,
mi : initial,
lname : lastName,
generation : generation,
username : userName
}
} )

.done( function( resultObject ) { // handle a successful lookup
console.log( 'Username lookup success' );
userNameExists = resultObject.exists;
}) // end .done

.fail( function() { // handle a failed lookup
console.log( 'Username lookup failure' );
}) // end .fail

.complete' is undefined)
lookupUserName (username-functions.js:28)
(anonymous function) (index.php:457)
dispatch (jquery.min.js:2:40041)
trigger (jquery.min.js:2:70130)
simulate (jquery.min.js:2:70640)
o (jquery.min.js:2:43239)


Подробнее здесь: https://stackoverflow.com/questions/792 ... is-failing

Вернуться в «Jquery»