0
我在點擊一個按鈕並進行一些驗證後,有一個頁面重定向的問題。我已經嘗試了多次soluitons,並繼續得到相同的結果,其中地址欄填充url但不重定向。如果我使用f5刷新或單擊瀏覽器的刷新按鈕比它工作和頁面重定向並加載正常。這是在我嘗試過的所有瀏覽器上。所以我必須錯過某些東西或做錯事。下面是我的代碼:JS頁面重定向沒有觸發
........
..............
//render function for json + templates like handlebars, xml + xslt etc.
render: function (dataItem, statuses) {
$list.html(template(dataItem.content));
// action button events
//$('.action a').on("click",function (e){
$('.action a').bind('click', function(e){
var $this = $(this),
action = $this.attr("action"),
$id = $this.closest('ul').attr('id');
// get which link was click for appropriate action
switch(action){
case 'prev' :
break;;
case 'edit' :
if($this.hasClass("actionEnabled")) {
$().ajaxCall(checkURL,{'ID':$id})
.done(function(data){
if(data.result == 0) {
var baseURL = window.location.href.replace(window.location.hash, '') + '#',
url = baseURL + secondUrl_part + "?ID=" + $id;
// url = "http://mysite/index.php#/page/destPage.php?ID=idabcdefgh"
// tried with javascript all these different methods -> still did not work
// method 1
$(location).attr('href', "http://mysite/index.php#/page/destPage.php?ID=idabcdefgh");
// method 2
window.location = "http://mysite/index.php#/page/destPage.php?ID=idabcdefgh";
// method 3
window.location.href = "http://mysite/index.php#/page/destPage.php?ID=idabcdefgh";
// method 4
window.location.replace("http://mysite/index.php#/page/destPage.php?ID=idabcdefgh");
// even tried with return false as suggested by some people
//return false;
} else {
// todo error message no longer exist
}
})
.fail(function(){
// todo error : could not be loaded
})
} else {
e.preventDefault();
// to do add message cannot edit
}
break;;
case 'del' :
break;
}
});
}
..........
.......
.....
你爲什麼要紀念與'php'標籤這個問題? – FirstOne
這個工程如果你重新加載頁面F5? –
@ Ivan Karaman:是的,如果我打F5的話,我會加載。 @FirstOne:我添加了PHP,因爲我試圖重定向到一個PHP頁面,不知道這是否有所作爲。 – boulepick