How to use ajaxError() Method in JQuery AJAX

In this article, I will explain use of ajaxError() Method in JQuery AJAX.
  • 2949

JQuery AJAX ajaxError() Method

  • ajaxError() method add a function to be execute when an AJAX request completes with an error.

  • ajaxError() method is a AJAX Event.



function(event,xhr,options)  The function is run when the request is fail.

  • event - Event parameter contains the event object.

  • xhr - xhr parameter contains the XMLHttpRequest object.

  • options - option parameter contains the options used in the AJAX request.

  • exc - exc parameter contains the JavaScript exception.



The following example show the use of ajaxError() method.


<!DOCTYPE html>



<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("div").ajaxError(function () {

            alert("Error occured in select file...!");


        $("button").click(function () {







<div><h2>error() method example</h2></div>

<button>click for change article text</button>





You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.