How to find out which Javascript causes a jQuery Ajax request?

前端 未结 3 888
借酒劲吻你
借酒劲吻你 2020-12-12 13:38

How to find the Javascript code from where a Ajax request triggered? In Firebug\'s console we are able to identify the file and line number, but if we\'re using $.ajax

3条回答
  •  悲哀的现实
    2020-12-12 14:16

    This may not have existed in earlier Chrome versions, but Version 56.0.2924.87 has an 'Initiator' column that tells the html/ js file and exact line within that file that initiated the request.

    This request can be XHR, http request for jpg, css or anything else.

    Pretty sleek and helpful in tracing back requests.

    Here's how to use it?

    1. Press "F12" to open the developer console.
    2. Look for "Initiator" column in each request, you can see "jquery.min.js:4", which means the request was initiated from the 4th line of the file "jquery.min.js".

提交回复
热议问题