jQuery ajaxError() Method

jQuery ajaxError() method to be called when AJAX request completes with an error. Whenever an Ajax request completes with an error jQuery triggers the ajaxError event.


Here is a syntax for ajaxError() method

$(selector).ajaxError( function(event, jqXHR, options, thrownError) );
Parameter Type Description
function(event, jqXHR, options) Function Required. A specifies callback function to be run when the request an error.
Additional parameters
  • event - contains standard event object
  • jqXHR - contains the XMLHttpRequest object
  • options - contains plain object used in the AJAX request
  • thrownError - contains the JavaScript exception to throw an error


Here, in this example ajaxError() method call when click on button.

<!DOCTYPE html>
  <title>jQuery ajaxError() event method</title>
  <script src="jquery-latest.min.js"></script>
    $(document).ready(function() {
        $("#complate").text("File not found! Probably removed.");
  <p id="complate">Response</p>
  <button>Click here to call ajaxComplete() method</button>
  <br /><br />
  <div id="msg" style="background-color:pink;">New contains update here</div>

Run it...   »