Unified processing of front-end ajax errors

Recently, the front-end ajax will be buried, so I wonder if it can be handled uniformly.

Later, I found ajaxSetup to uniformly encapsulate the error and function inside. 

<script type="text/javascript">
$.ajaxSetup({error:function( xhr,error,status ){
     console.log(this.url)
}})

$.ajax({url:'Abc1111111111111',success:function(data){
    console.log(data);
}})

</script>

By getting the url, the corresponding business is found and processed uniformly.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324969550&siteId=291194637