Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.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 如何使用ajax刷新div中更新的表行_Javascript_Jquery_Html_Ajax - Fatal编程技术网

Javascript 如何使用ajax刷新div中更新的表行

Javascript 如何使用ajax刷新div中更新的表行,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我需要您帮助刷新div=“table”,它有一个从数据库检索行的表 <div id="table"> <h1 id="Requests"> <table></table> </h1> </div> <button id="refresh-btn">Refresh Table</button> <script> $(document).ready(func

我需要您帮助刷新div=“table”,它有一个从数据库检索行的表

<div id="table">
    <h1 id="Requests">
        <table></table>
    </h1>
</div> 
<button id="refresh-btn">Refresh Table</button>
<script>
$(document).ready(function() {

   function RefreshTable() {
       $( "#table" ).load( "requests.html #table" );
   }

   $("#refresh-btn").on("click", RefreshTable);
});
</script>

刷新表
我尝试使用下面的jquery,但是它正在刷新div,而没有从数据库中获取更新

<div id="table">
    <h1 id="Requests">
        <table></table>
    </h1>
</div> 
<button id="refresh-btn">Refresh Table</button>
<script>
$(document).ready(function() {

   function RefreshTable() {
       $( "#table" ).load( "requests.html #table" );
   }

   $("#refresh-btn").on("click", RefreshTable);
});
</script>

$(文档).ready(函数(){
函数刷新表(){
$(“#table”).load(“requests.html#table”);
}
$(#刷新btn”)。在(“单击”,刷新表格);
});
删除表格

 <script>
  $(document).ready(function() {

   function RefreshTable() {
   table.innerHTML = '';
   $( "#table" ).load( "requests.html #table" );
   }

   $("#refresh-btn").on("click", RefreshTable);
});

$(文档).ready(函数(){
函数刷新表(){
table.innerHTML='';
$(“#table”).load(“requests.html#table”);
}
$(#刷新btn”)。在(“单击”,刷新表格);
});

它正在加载一个html文件,该文件是静态的,因此不会查询数据库。要使用ajax从数据库获取数据,您需要某种类型的服务(node、php、.net等),该服务具有查询数据库和格式化html表行输出的功能,但是,如何更新表的一部分不仅是整个jspIt的愚蠢之处,而且可以删除表中的所有元素,并在click函数中添加新值。代码可以是table.innerHTML=''@99maas您将问题表述为:“……它正在刷新div,而没有从数据库中获取更新。”也许下次使用“it”一词时,您可以进一步阐述一下您的意思