How can I view the previous GET request in JavaScript? Actually what I am after, I can see my firebug console. When XMLHttpRequests are being shown in the console, I see a row that looks like this:
Obtain http://www.domain.com/php/file.php?q0& ; C = 1 200 ok 163ms
How do I see that URL in javascript?
Edit: To be clear, I am looking for URL between GET ... and ... 200. I do not care about anything else. I do not want any other information.
You can modify the XMLHttpRequest .prototype.open
on your " Tracking "with code. Something like this:
var ajaxCalls = []; XMLHttpRequest.prototype._originalOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (method, url, async, user, password) {ajaxCalls.push (url); This._originalOpen (method, url, async, user, password); }
Ajax files will be populated with the url of your Ajax requests. The last request will be on
ajaxCalls [ajaxCalls.length - 1]
.
Note that if you only want to track the GET
requests, then you simply log code only in method === 'GET'
open ()
method.
Comments
Post a Comment