2013-07-05 95 views
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調用,等待實際響應,並逐步完成適當的代碼塊?

回答

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; 
    }); 
+0

這個偉大的工程,謝謝! –