我正在尝试关闭一个模式,然后在使用AJAX发生错误时打开另一个模式。但是,它似乎在error
函数中不起作用。它在success
函数中正常工作。
$('#modSending').modal({
backdrop: 'static',
keyboard: false
});
$.ajax({
url: '/api/myapi/saverep?id=' + tid,
dataType: 'json',
type: 'POST',
contentType: 'application/json; charset=utf-8',
success: function(result) {
//this part is working
$('#modSending').modal('hide');
$('#lblAlertHead').text("MySystem - Success");
$('#pMessage').text("Request has been save.");
$('#modAlert').modal({
backdrop: 'static',
keyboard: false
});
$('#btnAlertMsg').attr('onclick', "$('#modAlert').modal('hide')")
$('#txtCategory').val('');
cat_loadDetails(tg);
},
error: function(xhr) {
var getxhr = $.parseJSON(xhr.responseText);
//close modal modSending
$('#modSending').modal('hide');
$('#lblAlertHead').text("MySystem - Error");
$('#pMessage').text(getxhr.Message);
$('#btnAlertMsg').attr('onclick', "$('#modAlert').modal('hide')");
//open modal modAlert
$('#modAlert').modal({
backdrop: 'static',
keyboard: false
});
return;
}
});