Edentity Web Systems
You solve creative. We crack code.
/Header/WhoWeAre.jpg
 

12/16/2009 Catching errors on the jQuery's load() function
Posted by Osvel Legon

When using the jQuery's load function there is a way to catch the errors. The callback is full of parameters from the request and the response:

$("body").load("/load.aspx", function (responseText, textStatus, XMLHttpRequest) {
    if (textStatus == "error") {
       alert('Error!');
       // XMLHttpRequest.responseText has the error info you want.
       alert(XMLHttpRequest.responseText);
    }
});

The XMLHttpRequest is a full XMLHttpRequest object.

Also you can register a general error handler for all the jQuery ajax calls:

$.ajaxError(function(event, request, settings) {
      alert("Oops!!");
});

 

« Back to Blog Main Page |

0 Comment(s)

Leave Comment

Name:
Comment:  
 
Edentity Web Systems Inc.
Suite 201
40 Spadina Ave.
Toronto ON
M5V 2H8
Tel:
416.591.2500
Fax:
416.352.5270

From Our Blog

02/09/2010
Amazon S3 – Now with Versioning! Posted by Joel Varty
02/02/2010
01/19/2010
411 Length Required in Firefox 3 Posted by Andre Small
Home | Who We Are | What We Do | Clients & Brands | Careers | Contact

Copyright © 2010 Edentity Web Systems Inc. Privacy Policy