当前位置: 动力学知识库 > 问答 > 编程问答 >

ajax - Capture HTTP requests with Javascript

问题描述:

is it possible with javascript to listen for and capture outgoing HTTP requests? (For example, AJAX calls). Sort of like firebug, etc

网友答案:

Sure, you can trace AJAX requests on your own pages. Make a wrapper for the XMLHttpRequest constructor that records the information you're interested in.

EDIT: An extension lets you observe internal browser operations. For example, you can see in Firebug's source that it observes all of Firefox's HTTP topics. These are "http-on-modify-request", "http-on-examine-response", and "http-on-examine-cached-response."

网友答案:

Nope, not like firebug. The closest thing you can do, if you're using a framework such as jQuery or Microsoft AJAX.NET, you can be notified when an AJAX request is issued through that specific framework.

For jQuery, that's .ajaxStart()

There are heaps of requests that this won't catch, though, such as all requested assets (script files, images, etc.)

网友答案:

If you want to capture all HTTP requests, I would suggest using Charles. Its an awesome tool which works as proxy and gives result in human readable form.

Shows Request, Response, Time Chart. The request is shown with headers. Response is shown with headers along with content. Worth trying it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: