I am trying to debug some JQuery ajaxSetUp
behaviour. I set a timeout value and wish to see it set in the debugger. To do this I need to know what to watch while debugging. To investigate where the timeout is set, I do the following in a firefox console:
var obj = jQuery.ajaxSetup({
timeout: 120000
});
console.log("obj=" + obj.timeout)
I want to find out what type of object obj
is? I know JavaScript is dynamically typed but if I can find out what object it is then I know what to add a watch to when debugging.
I am trying to debug some JQuery ajaxSetUp
behaviour. I set a timeout value and wish to see it set in the debugger. To do this I need to know what to watch while debugging. To investigate where the timeout is set, I do the following in a firefox console:
var obj = jQuery.ajaxSetup({
timeout: 120000
});
console.log("obj=" + obj.timeout)
I want to find out what type of object obj
is? I know JavaScript is dynamically typed but if I can find out what object it is then I know what to add a watch to when debugging.
- You want to know that obj is really an object from ajax Setup? Not going to happen. – epascarello Commented Apr 29, 2013 at 14:07
5 Answers
Reset to default 3Type of obj
is object
. See:
typeof obj
// "object"
Also, the constructor is global javascript Object
. Here:
obj.constructor.name
// "Object"
jQuery has a few utility methods like .isArray()
, .isFunction()
, .isNumeric()
and .isPlainObject()
that return true or false. Use these one after the other to determine whether an object is of a specific type.
there is special function in jquery
jQuery.type(obj)
You can use the typeof
operator.
This wasn't a good approach for this problem. I looked at the JQuery source and saw when you invoke ajaxSetUp it updates the jQuery.ajaxSettings object.
So if you do...
console.log(jQuery.ajaxSettings.timeout)
in the debug console you'll get the value.
I am putting answer here in case it is use to anyone.