douqie1816 2016-08-11 05:13
浏览 40

当在AJAX,Jquery中使用GET更新数据库时,如何反映表上的更新

I have a table in my php file that is displayed using datatables. Upon clicking on a link in a row of the table, the database is updated using Jquery and GET AJAX. My database is getting updated, but table does not reflect the changes without a manual refresh. How do I make it possible, for the table values to reflect the changes immediately after the button is clicked. Code below:

$("#note").click(function(){
                var note = prompt('Enter note');

                if(note){ 

                    var xmlhttp = new XMLHttpRequest();
                    xmlhttp.onreadystatechange = function() {
                        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
                        {
                            alert("Record updated");
                        }
                    };
                    xmlhttp.open("GET", "db_update.php?id="+id+"&note="+note, true);
                    xmlhttp.send();


                    /* $.get("db_update.php", { id: id[$index], note:note });  */
                }
                return false;

            });

Please advise.

  • 写回答

2条回答 默认 最新

  • duanmu5039 2016-08-11 05:16
    关注

    If you are using jquery datatable than this will help you:

    $('#table_id').DataTable().ajax.reload();
    

    otherwise make an ajax call to get the updated data from the database

    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭