点击拒绝按钮我正在调用函数,如下所示
function reject(message, document_id, status) {
var ajaxdo = $.ajax({
type: 'GET',
url: url + '/OMS/admin/UpdateAdminCategory?document_id=' + document_id + '&message=' + message + '&status=' + status,
jsonpCallback: 'jsonCallback',
dataType: 'jsonp',
jsonp: false,
success: function(response) {
},
error: function(e) {
alert('Error inside Fill form request');
}
});
ajaxdo.done(function() {
finalcall();
});
}
function finalcall() {
var vendor_brand_id = $('#BrandNames').val();
$("#textandsavediv").hide();
showT1(vendor_brand_id, '');
}
function showT1(vendor_brand_id, t1categorytext) {
var ajaxq = $.ajax({
type: 'GET',
url: url + '/OMS/admin/categorylevelservice?vendor_brand_id=' + vendor_brand_id + '&reqstr=' + t1categorytext,
jsonpCallback: 'jsonCallback',
dataType: 'jsonp',
jsonp: false,
beforeSend: function() {
$('#T1').html('<img src="input-spinner.gif" alt="" width="24" height="24">');
},
success: function(response) {
displayT1(response, t1categorytext)
},
error: function(e) {
alert('Error inside Fill form request');
}
});
}
function displayT1(response, t1categorytext) {
$("#T1").append(html);
}
我面临的问题是Ajax响应混乱
请告诉我如何解决这个问题?
答案 0 :(得分:0)
将所有内容整理出来并做出适当的回报,我最终得到了这个,这可能会解决问题:
function reject(message, document_id, status) {
return $.ajax({
type: 'GET',
url: url + '/OMS/admin/UpdateAdminCategory',
data: {
'message': message,
'document_id': document_id,
'status': status
},
jsonpCallback: 'jsonCallback',
dataType: 'jsonp',
jsonp: false
}).then(function(response) {
$(".saveclassbtn").hide();
var vendor_brand_id = $('#BrandNames').val();
$("#textandsavediv").hide();
return showT1(vendor_brand_id, '');
}).then(null, function(e) {
console.log('Error inside Fill form request');
return e;
});
}
function showT1(vendor_brand_id, t1categorytext) {
return $.ajax({
type: 'GET',
url: url + '/OMS/admin/categorylevelservice',
data: {
'vendor_brand_id': vendor_brand_id,
'reqstr': t1categorytext
},
jsonpCallback: 'jsonCallback',
dataType: 'jsonp',
jsonp: false,
beforeSend: function() {
$('#T1').html('<img src="input-spinner.gif" alt="" width="24" height="24">');
}
}).then(function(response) {
// Process data and set data
$("#T1").append(html);
}).then(null, function(e) {
console.log('Error inside Fill form request');
return e;
});
}
请致电如下:
reject(...).then(function() {
//do whatever on overall completion
}).fail(function(e) {
console.Error(e);
});