Which is a better underlying function than getjson? What are the advantages

Time:2021-7-3
Copy codeThe code is as follows:
$.ajax({
type: “GET”,
url: desturl,
success:function(data) {
if(data!=”) {
linfo.innerHTML=data;
}
loadimg.style.display=”none”;
// addTableListener(document.getElementById(“tbColor”),0,0);
},
error: function(){
Alert (“asynchronous query error”);
loadimg.style.display=”none”;
},dataType:”json”

});

The advantage is that if there is a problem with the network, the error method can be used to tell the user that there is an error. If you use the getjson function, you cannot handle this error