Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.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中使用GET变量重新加载URL_Javascript_Jquery - Fatal编程技术网

Javascript 在Jquery中使用GET变量重新加载URL

Javascript 在Jquery中使用GET变量重新加载URL,javascript,jquery,Javascript,Jquery,我正在尝试重新加载URL中附加了变量deviceID的页面。它在“实时”栏目中显示得很好。我做错了什么 document.getElementById("realtime").innerHTML = "<pre>"+JSON.stringify(msg)+"</pre>"; var obj = jQuery.parseJSON(JSON.stringify(msg)); var deviceId = obj.deviceId;

我正在尝试重新加载URL中附加了变量deviceID的页面。它在“实时”栏目中显示得很好。我做错了什么

document.getElementById("realtime").innerHTML = "<pre>"+JSON.stringify(msg)+"</pre>";

        var obj = jQuery.parseJSON(JSON.stringify(msg));
        var deviceId = obj.deviceId;

        var pathname = window.location.pathname;
        var pathAppend = pathname + "?deviceId=" + deviceId;

            window.location.reload(pathAppend);
document.getElementById(“realtime”).innerHTML=“”+JSON.stringify(msg)+”;
var obj=jQuery.parseJSON(JSON.stringify(msg));
var设备ID=对象设备ID;
var pathname=window.location.pathname;
var pathpappend=pathname+“?deviceId=“+deviceId;
window.location.reload(路径附加);

这是因为您使用的
window.location.reload不正确<代码>重新加载
接受以下布尔值:

如果为true,则会导致页面始终从服务器重新加载。如果为false或未指定,浏览器可以从其缓存重新加载页面。-

你应该这样做:


请提供更多的代码。您想更新整个页面还是只更新其中的一部分,例如div元素?你的问题我不清楚。对不起,我想重新加载整个页面!添加了最后一行。在
http://whatever.com/index?deviceId=500
将复制参数
http://whatever.com/index?deviceId=500&deviceId=530
var query = window.location.search, deviceParam = "deviceId=" + deviceId;

//if there is a query string, append it, otherwise construct the query string.
query += (query === "" ? "?" : "&") + deviceParam;

window.location.search = query; // page should reload