2013-04-01 48 views
0

我發送的請求與angular.js$http並得到了一些響應,之後我必須更新頁面,並呼籲timer功能:執行窗後函數替換

$http({method: 'POST', url: url_api, data: {login_username: username, login_password: password}}).success(function(data, status, headers, config) { 
// parse data 
.... 
window.location.replace("/"); 
// call timer 
timer(); 
} 

其中timer

function timer(){ 
    document.getElementById("span_count_down").innerHTML = 'Time is out!'; 
    return; 
} 

但是,當我更新頁面,我沒有看到Time is out!innerHTML,我看到以前的innerHTML

謝謝。

回答

1

當您致電location.replace()時,頁面被卸載並且不再執行腳本。當新頁面加載時,您的腳本不會執行,因爲它未在此頁面上調用。