0

我试图通过一些代码来找出我的应用程序中的奇怪行为。

当我到达 $http.post 函数调用时,我只能单步执行函数调用、.success 函数调用和 .error 函数调用。

我永远无法等待响应并逐步执行相应的代码块。

$http.post("php/someFunction.php")
  .success(function(data, status)
  {
    ... do thing ONE;
  })
  .error(function(data, status)
  {
    ... do thing TWO;
  });

在这个例子中,我永远无法通过一件事或二件事。

是否有任何调试技巧或工具可用于实际执行 ajax 调用、等待实际响应并逐步执行相应的代码块?

4

1 回答 1

0

尝试debugger声明:

$http.post("php/someFunction.php")
  .success(function(data, status)
  {
    debugger; // debugger will kick in if success
    ... do thing ONE;
  })
  .error(function(data, status)
  {
    debugger; // debugger will kick in if error
    ... do thing TWO;
  });
于 2013-07-05T16:07:47.027 回答