Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery地址更改未使用不同的URL触发?_Javascript_Jquery_Browser Cache_Jquery.address - Fatal编程技术网

Javascript jquery地址更改未使用不同的URL触发?

Javascript jquery地址更改未使用不同的URL触发?,javascript,jquery,browser-cache,jquery.address,Javascript,Jquery,Browser Cache,Jquery.address,我撞到墙了。我的设想根本没有道理。我正在使用jquery地址pluglin 这是我的问题: 用户使用如下参数输入url: http://localhost/#view_profile=1 jquery address change函数认为它很好,并调用适当的方法: $.address.change(function(e) { var urlAux = e.value.split('='); var page = urlAux[0]; var arg = urlAux[1]; aler

我撞到墙了。我的设想根本没有道理。我正在使用jquery地址pluglin

这是我的问题:

用户使用如下参数输入url:

http://localhost/#view_profile=1
jquery address change函数认为它很好,并调用适当的方法:

$.address.change(function(e) {

var urlAux = e.value.split('=');
var page   = urlAux[0];
var arg  = urlAux[1];

alert("page: " + page);
alert("arg: " + arg);

if (page == "/view_profile") {

    $.address.title("Profile");

    $('#main').load("view_profile.php?id=" + arg, function () { 
    alert("FUNCTION CALLED");
    });
}
....
现在,这是我的问题;用户输入一个新的URL,如下所示:

http://localhost/#view_profile=2
地址更改被触发,但它永远不会进入我的if块。如果我第二次输入相同的地址,它会触发If块中的代码

这是一个已知的问题,还是与页面缓存有关

第一个URL的输出:

page: /view_profile
arg: 1
FUNCTION CALLED
第二个URL的输出:

page: /view_profile
arg: 2
**** Why is the if block not being triggered? ***
第二个URL(AGIA)的输出:

我被难住了…

在if语句之前尝试一下alert(page==“/view\u profile”)。。。或者在开始时在你的区块内放置另一个警报。。。也许问题不在于if语句
page: /view_profile
arg: 2
FUNCTION CALLED