处理ajax错误

$.getJSON("test.php", function(json) {
   ... this function handles success
});

How do I handle errors for the current $.getJSON?

I don't think there is a direct option available using getJSON, instead use the ajax method:

$.ajax({
  url: "test.php",
  dataType: "json",
  data: data,
  success: function(data){
  },
  error: function(data){
   //ERROR HANDLING
  }
});

Check out the documentation for the jQuery.ajax function.

It will let you create a GET request with an error and success callback.

An example:

jQuery.ajax({
   url:     "test.php",
   type:    "GET",
   success: function() { //... },
   error  : function() { //... }     
});

Two options:

$.ajaxError(function(){});

or you can switch to $.ajax and use the error property:

$.ajax({
  url: url,
  dataType: 'json',
  data: data,
  success: callback,
  error: function(){
  }
});

Why not do it like this instead so you can specifically handle the error

$.ajax({
  url: url,
  dataType: 'json',
  data: data,
  success: function(data){}
  error: function(data){}
});

or you can use the global ajaxError