2

Ive got some particularly nasty Javascript I am trying to debug. Specifically, I am trying to determine what functions are making certain http requests. Due to the shear size of the .js file and the generally poor quality, it is not as easy as hunting through the file manually.

I am vaguely experienced with Fiddler and Firebug, is this a capability built into those applications? Is there a better way to do this, if it is even possible?

3 Answers 3

3

Regardless of size or quality of the file, you should be able to grep for the keyword 'XMLHttpRequest' and set breakpoints where it's used.

You could also, on page load, before anything else is called, monkeypatch the XMLHttpRequest global:

var open = XMLHttpRequest.open;
XMLHttpRequest.open = function(){
  console.log(this, arguments);
  return open.apply(this, arguments);
};

Or something more sophisticated.

Sign up to request clarification or add additional context in comments.

Comments

2

In the development version of Google Chrome you now have the ability to break the code on any XHR that is made. (wrench > tools > developer tools) alt text

Comments

1

Yup! In firebug go to 'Net' on the top menu and choose 'XHR' from the menu right below to see all ajax calls being made during a visit to the page. This will display a wealth of information like the duration of the calls, and request / response headers.

3 Comments

I don't think it tells you what functions fire the request, just information surrounding the details of the request itself.
true... thought i had seen it in there somewhere but i was wrong.
That should help narrow down some of the potential code-triggers, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.