$.ajax and error handling

$.ajax and error handling

Hi,

I've a question about ajax and the error handling. What I'm trying to do is to force to go in the error callback but it doesn't work because I'm supposed get an JSON array back.

My code (simplified):

  1.             $.ajax({
  2.                 url: 'list.php',
  3.                 async: true,
  4.                 success: function(data, status, xhr) {
  5.                       // Some code
  6.                 },
  7.                 error: function(xhr, msg, exception) {
  8.                       // Some code
  9.                 }
  10.            });

list.php

  1. $error = array("error" => "Throw custom error");
  2. echo json_encode($error);
  3. // ??? How I can I quit with errors and throwing my JSON in the error callback?

Thanks !