?
Solved

Reading error values from ajaxError

Posted on 2014-09-23
4
Medium Priority
?
137 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 750 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

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

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 …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)
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…
Suggested Courses

762 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