Reputation: 8042
Is the info that Firebug shows under various tabs available also within the console?
E.g. within the command line I can create objects, do simple math, execute JavaScript etc. For example I can create an object for an HTTP request:
var request = new XMLHttpRequest();
But I am wondering if there is some 'global' variable, which actually holds the request
variable and which I can read from. Something like:
console.log(global_http_request.referring_url);
Please note, I am not aware of how to show the referring URL from which I've come to the current page (for this I can use e.g. Firefox' Tools > Page info and search for "Referring URL" or Firebug's Net panel and filter by XHR).
I've tried this (within the console) to access the referring URL, but with no luck:
var request = new XMLHttpRequest();
undefined
console.log(request.HEADERS_RECEIVED)
2
console.log(request.HEADERS_RECEIVED.valueOf)
valueOf()
console.log(request.HEADERS_RECEIVED.toString)
toString()
console.log(request.HEADERS_RECEIVED.toString())
2
console.log(request.HEADERS_RECEIVED.valueOf())
2
console.log(request.getAllResponseHeaders.name.valueOf.toString())
function valueOf() {
[native code]
}
console.log(request.getAllResponseHeaders())
(an empty string)
Upvotes: 0
Views: 99
Reputation: 2376
There's lots of data you cannot get using standard JS, but which Firebug has access to because it runs with higher privileges than the web page. I think response headers are run through a black list, for instance.
However, if you just want JS access to the data for simplified debugging, you should be able to get that in Firebug by right-clicking the XHR object and picking "Use in Command Line".
Upvotes: 1
Reputation: 1038720
But I am wondering if there is some 'global' variable which actually holds my actual XMLHttpRequest() and which I can read from ?
This global object is called window
.
Upvotes: 0