Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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在html页面之间传递参数_Javascript_Jquery_Html - Fatal编程技术网

Javascript 使用jquery在html页面之间传递参数

Javascript 使用jquery在html页面之间传递参数,javascript,jquery,html,Javascript,Jquery,Html,我有一个包含jquery函数的html页面 <script> function loadCustomers() { $.ajax({ type: 'GET', url: 'http://localhost:8080/cache/getCustomers', dataType: 'json', success: function(data) { var rows = [];

我有一个包含jquery函数的html页面

<script>
function loadCustomers() {
    $.ajax({
        type: 'GET',
        url: 'http://localhost:8080/cache/getCustomers',
        dataType: 'json',
        success: function(data) {
            var rows = [];
            $.each(data,function(id,value) {
                rows.push('<tr><td><a href="clientSiteInfo.html?client=">'+id+'</td><td>'+value+'</td></tr>');
            });
            $('table').append(rows.join(''));
        }
    });
};
window.onload = loadCustomers;
</script>

函数loadCustomers(){
$.ajax({
键入:“GET”,
网址:'http://localhost:8080/cache/getCustomers',
数据类型:“json”,
成功:功能(数据){
var行=[];
$.each(数据、函数(id、值){
行推送(“”+id+“”+value+“”);
});
$('table').append(rows.join('');
}
});
};
window.onload=loadCustomers;
我已经为每一行链接了另一个html页面。填充每行时,必须将id值传递到clientSiteInfo.html页面

clientSiteInfo.html页面中,我有另一个类似于上面的jquery函数

<script>
function loadSites() {
    $.ajax({
        type: 'GET',
        url: 'http://localhost:8080/cache/getSite?clientName='+${param.client},
        dataType: 'json',
        success: function(data) {
            var rows = [];
            $.each(data,function(id,value) {
                rows.push('<tr><td>'+id+'</td><td>'+value.machine+'</td><td>'+value.state+'</td></tr>');
            });
            $('table').append(rows.join(''));
        }
    });
};
window.onload = loadSites;
</script>

函数loadSites(){
$.ajax({
键入:“GET”,
网址:'http://localhost:8080/cache/getSite?clientName='+${param.client},
数据类型:“json”,
成功:功能(数据){
var行=[];
$.each(数据、函数(id、值){
行。推送(“”+id+“”+value.machine+“”+value.state+“”);
});
$('table').append(rows.join('');
}
});
};
window.onload=加载站点;
在GET url中,我尝试读取客户机参数。但这并不是从我的第一页开始的


我做错了什么?我寻找简单的解决方案

jQuery没有读取url参数的本机方法。但是,javascript工作得很好:

function getParameterByName(name) {
  const match = RegExp(`[?&]${name}=([^&]*)`).exec(window.location.search);
  return match && decodeURIComponent(match[1].replace(/\+/g, ' ') );
}

在您的代码中,您可以将其命名为
getParameterByName('client')

谢谢,但从我的第一个html来看,它似乎没有传递任何客户端值抱歉,我的错误,一个“'