1

I have a function which makes a post request to my server when a button is clicked, however I notice in the console log that a single request is being sent to that resource when when it shouldn't have been triggered and I don't know why.

It is seemingly triggered a short time after another function is called which makes a get request to another resource, however that function is fairly simple; I've looked through it on and off for the past couple days and am at a loss and so have just been ignoring it mostly.

It's not really causing interference in the program, it just throws an exception on the server and the request fails which has no reprocussions to the client either, but obviously I don't want that in production and it's bothering me because I just can't figure it out. I really cannot imagine it's being triggered there and it's also strange because it happens some amount of time after that call, not right after as you'd think if it were called by it directly. So anyway, short of stepping through my whole program is there any way to determine what called a function? I'd think it would be a fairly common feature, but I just can't seem to find it if so.

4

2 回答 2

1

你可以在代码中使用console.trace(),还是不能编辑代码?

于 2013-11-13T16:27:52.327 回答
0

一些用于跟踪的代码(每行在控制台上都有这样的跟踪样式):

console.log(object[, object, ...])
console.debug(object[, object, ...])
console.info(object[, object, ...])
console.warn(object[, object, ...])
console.error(object[, object, ...])
....

官方文档(如果您使用 Firebug): https ://getfirebug.com/wiki/index.php/Console_API

于 2013-11-13T16:32:01.760 回答