Solved

Reading error values from ajaxError

Posted on 2014-09-23
4
133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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)

726 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