Sha*_*mar 8 javascript ajax jquery
在我的Jquery中,我正在使用Ajax并获得低于错误的消息.
TypeError: $.ajax(...).done is not a function
[Break On This Error] ).success(function(response) {
Run Code Online (Sandbox Code Playgroud)
我厌倦了使用成功而不是完成.但仍然得到相同的消息.
TypeError: $.ajax(...).success is not a function
[Break On This Error] ).success(function(response) {
Run Code Online (Sandbox Code Playgroud)
示例代码段如下:
$(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);
});
Run Code Online (Sandbox Code Playgroud)
Kon*_*ole 11
更换你success用done或使用AJAX功能内的成功.
成功回调选项的替代构造,.done() 方法替换了不推荐使用的jqXHR.success()方法.
例如
$(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);
}
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
36756 次 |
| 最近记录: |