now there is a requirement to show the load component before the request and hide the load display immediately after the request is completed. But the Ajax value provides four callback functions: beforeSend,success,error,complete. To hide the load shows the component, either in success and error to add hidden load logic, or in the complete function to add once, but in this way if an exception occurred in the success function, you will not go to the complete function, it will not be able to hide the loading component, is there any way to write only once hidden load logic?
$.ajax({
url: url,
data: this.reqSearch,
complete:function(XMLHttpRequest,textStatus){
that.$Spin.hide();
},
success: function(res) {
......
},
error: function(){
......
}
})