javascript 刷新表格而不刷新整个页面以显示更新的数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13986437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Refresh a table without refreshing entire page to show updated data
提问by Vineesh Kalarickal
I wish to show newly added data to a listing page, which listed on the same page. My problem is that after adding data to my database I needed to reload entire page to see the new data. How can I view without reloading entire page?
我希望将新添加的数据显示到在同一页面上列出的列表页面。我的问题是,将数据添加到我的数据库后,我需要重新加载整个页面才能看到新数据。如何在不重新加载整个页面的情况下查看?
回答by Prasad Rajapaksha
If you only want to refresh the table, you can use this jQuery plugin: http://datatables.net
如果只想刷新表,可以使用这个 jQuery 插件:http: //datatables.net
You can call table refresh functions whenever you want. The plugin works using AJAX. To work with you need to have little javascript knowledge as well.
您可以随时调用表刷新函数。该插件使用 AJAX 工作。要与您一起工作,您还需要具备很少的 javascript 知识。
You can find sort of example/demo from here. http://editor.datatables.net/tutorials/api_manipulation
您可以从这里找到一些示例/演示。 http://editor.datatables.net/tutorials/api_manipulation
However if you really want to do this get the concept and you also can develop same thing. You just require to learn some AJAX.
但是,如果您真的想这样做,请了解概念,您也可以开发相同的东西。你只需要学习一些 AJAX。
回答by Rajesh
in Button click after data saved to database you need to use following script. no need to go round trips to server to client instead manipulate client side.
在将数据保存到数据库后单击按钮,您需要使用以下脚本。无需往返于服务器到客户端,而是操作客户端。
$("#btnSubmit").click(function () {
$('#myForm').ajaxForm({
success: function(){
$('#myTable tr:first').after('<tr><td>' + $("#Name").val() + '</td></tr>');
}
});
});