Solved

Reading error values from ajaxError

Posted on 2014-09-23
4
124 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
ID: 40338734
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
ID: 40338762
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
ID: 40338856
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
ID: 40348409
I found out what the other parameters contained in addition to the input from Radek.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…

856 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