Solved

Reading error values from ajaxError

Posted on 2014-09-23
4
120 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reference Error with plugin 1 39
Looking for a Responsive Photo Gallery w/thumbnail carousel recommendation 1 24
jquery easyautocomplete for mutiple text boxes 9 64
Jquery 10 20
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

777 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