Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  92] [ 3]  / answers: 1 / hits: 43231  / 11 Years ago, tue, september 3, 2013, 12:00:00

In my Jquery, i am using Ajax and getting below error msg.



TypeError: $.ajax(...).done is not a function
[Break On This Error] ).success(function(response) {


I tired using success instead of done. but still getting same msg.



TypeError: $.ajax(...).success is not a function
[Break On This Error] ).success(function(response) {


sample piece of code is mentioned below:



$(document).ready(function () {
alert('in get');
$.ajax({
data: {
'contentId': contentId,
'USER_ID': USER_ID,
'actionType': 'GETRATING',
'portletGuid': portletGuid
},
type: 'GET',
url: ajaxRatingServlet,
cache: false
}).success(function (response) {
getUserPreference(response);
});

More From » ajax

 Answers
35

Replace your success with done or use success inside ajax function.




An alternative construct to the success callback option, the .done()
method replaces the deprecated jqXHR.success() method.




EG



$(document).ready(function () {
$.ajax({
data: {
'contentId': contentId,
'USER_ID': USER_ID,
'actionType': 'GETRATING',
'portletGuid': portletGuid
},
type: 'GET',
url: ajaxRatingServlet,
cache: false
}).done(function (response) {
console.log(response);
});

//or use success inside ajax as other answered

$(document).ready(function() {
alert('in get');
$.ajax({
data: { 'contentId':contentId, 'USER_ID':USER_ID, 'actionType':'GETRATING', 'portletGuid':portletGuid },
type:'GET',
url:ajaxRatingServlet,
cache:false,
success: function(response) {
getUserPreference(response);
}
});
});

[#75935] Monday, September 2, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terrence

Total Points: 120
Total Questions: 115
Total Answers: 87

Location: England
Member since Fri, May 22, 2020
4 Years ago
terrence questions
Sat, Jun 5, 21, 00:00, 3 Years ago
Wed, Jun 17, 20, 00:00, 4 Years ago
;