Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.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 表不包括';t在Jquery中追加行_Javascript_Jquery_Html_Ajax - Fatal编程技术网

Javascript 表不包括';t在Jquery中追加行

Javascript 表不包括';t在Jquery中追加行,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我想请求一个子html页面,然后将其附加到另一个html,子html的内容有一个表 现在我想请求另一个ajax请求来请求表内容并将它们附加到表中 第一个请求(子html)页面成功,但我的代码没有将内容追加到表中 子html页面: <div class="Queue"> <h3>Queue</h3> <table class="table table-hover" id="driverQueueTable"> <thead>

我想请求一个子html页面,然后将其附加到另一个html,子html的内容有一个表

现在我想请求另一个ajax请求来请求表内容并将它们附加到表中

第一个请求(子html)页面成功,但我的代码没有将内容追加到表中

子html页面:

<div class="Queue">
<h3>Queue</h3>

<table class="table table-hover" id="driverQueueTable">
    <thead>
    <tr>
        <th>column 1</th>
        <th>column 2</th>
        <th>column 3</th>
        <th>column 4</th>
    </tr>
    </thead>
    <tbody></tbody>
</table>

队列
第1栏
第2栏
第3栏
第4栏

js代码:

$(document).ready(function () {
    $(".queue").click(function () {
        $.ajax({
            url: "sidebarContent/table",
            success: function (result) {
                $('.content').html(result);
            }
        });
        $("#driverQueueTable").find('tbody')
            .append($('<tr>')
            .append($('<td>').append($('<a>').text('Image cell')))
            .append($('<td>').append($('<a>').text('Image cell')))
            .append($('<td>').append($('<a>').text('Image cell')))
            .append($('<td>').append($('<a>').text('Image cell').attr('href', ''))));
    });
});
$(文档).ready(函数(){
$(“.queue”)。单击(函数(){
$.ajax({
url:“侧边栏内容/表格”,
成功:功能(结果){
$('.content').html(结果);
}
});
$(“#driverQueueTable”).find('tbody')
.append($('')
.append($('').append($('').text('Image cell'))
.append($('').append($('').text('Image cell'))
.append($('').append($('').text('Image cell'))
.append($('').append($('').text('Image cell').attr('href','');
});
});

我还没有为表内容请求第二个ajax,因为我正在尝试附加内容,但它不起作用。

您使用的表id是错误的。您应该将
#driverQueueTable
更改为
#myTable

$(文档).ready(函数(){
$(“#myTable”).find('tbody'))
.append($('')
.append($('').append($('').text('Image cell'))
.append($('').append($('').text('Image cell'))
.append($('').append($('').text('Image cell'))
.append($('').append($('').text('Image cell').attr('href',''))
);
});

队列
第1栏
第2栏
第3栏
第4栏

是否存在
.content