的位置.jquery事件中没有重定向

location.href not redirecting inside jquery event

本文关键字:重定向 事件 位置 jquery      更新时间:2023-09-26

我使用javascript, jquery和jquery移动版。我有这个:

$(document).ready(function() {
    $("#routes").change(function(){
        var newValue = $("#routes").val();
        if(newValue != -1){
            newLocation="http://localhost:8080/map.jsp?route="+newValue ;
            window.location.href=newLocation;
        }
    });
});

但是位置。Href没有重定向我。

任何想法?

编辑:

我得到了这个,它的工作现在,我的问题是,现在的map.jsp不去执行。ready事件:

        $.mobile.changePage('/map.jsp', {
            reloadPage: true,
            type: "get",
            data: 'route='+newValue
        });

根据Hogan的回答,他是对的,只是使用

window.location = newLocation; return false; ,因为我运行相同的问题,只使用窗口。location解决了我的问题

还有一件事你可能需要寻找的是#在url的结尾,我不知道,但有#在url的结尾不重定向当你使用window.location

use just

window.location=newLocation;