Solved

Reading error values from ajaxError

Posted on 2014-09-23
4
113 Views
Last Modified: 2014-09-28
I have added a JQuery error handler as follows:

		$( document ).ajaxError(function( event, request, settings ) {		  
		  alert("ERROR: event = " + event + ", request = " + request + ", settings = " + settings);
		});

Open in new window


However when I try to output the values I get [object Object] for each one. I simply want to output all the error information returned.

I know probably have to use the dot notation to extract the records but can someone refer me to a page where all the possible values are defined?
0
Comment
Question by:mike99c
  • 2
4 Comments
 
LVL 11

Assisted Solution

by:Radek Baranowski
Radek Baranowski earned 250 total points
Comment Utility
http://api.jquery.com/category/events/event-object/

can you show a bit of your code to understand what object types are under event, request and settings ?

you would be probably interested most in
event.type
or
event.target

as per others, I'm not sure what they bear, so can't really tell what reasonable info could be gotten from them :)

hope this helps
0
 

Accepted Solution

by:
mike99c earned 0 total points
Comment Utility
OK thanks for this. I have looked around some more and have settled on the following:

		$( document ).ajaxError(function( event, jqxhr, ajaxOptions, errorThrown ) {		  
		  alert("ERROR: \nevent = " + event.type + "\njqxhr.status = " + jqxhr.status + "\najaxOptions.url = " + ajaxOptions.url + "\nerrorThrown = " + errorThrown);
		});

Open in new window

0
 
LVL 30

Expert Comment

by:Alexandre Simões
Comment Utility
Next time just make sure you inspect the objects using any browser development tools.

Also console.log is more "friendly" than the alert and JSON.stringify(...) is sometimes useful to see the object structure as a string.
0
 

Author Closing Comment

by:mike99c
Comment Utility
I found out what the other parameters contained in addition to the input from Radek.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now