Tag: partial page refresh

AJAX Jquery刷新所有内容,但我只想要新内容

我可能正在重新发明轮子,但那是故意的。 我正在尝试使用PHP HTML MySQL CSS创建一个实时聊天应用程序。 它在网络上运行良好,并且每秒都能获取新内容。 在IE中你可以注意到每秒闪烁一次,看起来它一次又一次地拉动所有数据,即使没有新内容,我也不喜欢这样。 这是我的刷新JS代码: $(document).ready(function() { $(“#data”).load(“data.php”); var refreshId = setInterval(function() { $(“#data”).load(‘data.php’); }, 1000); $.ajaxSetup({ cache: false }); }); data.php只需一段时间循环遍历所有数据库记录并显示它们: while ($row = mysql_fetch_array($result)) { echo “”. $poster .”: “. $message .””. date(‘D d M – g:i:s a’, strtotime($row[‘when’])) .””; } 我看了看互联网上的解决方案,褪色等,我想不出怎么做到这一点,肯定有一些好的,简单有效的方法?

Lifehacker使用Ajax实现url更改

我看到Lifehacker能够在使用AJAX更新部分页面时更改URL。 我想这可以使用HTML5或history.js插件实现,但我想lifehacker既不使用也不使用。 有没有人知道他们是怎么做到的? 我是AJAX的新手,只是设法使用Ajax更新部分页面。 谢谢@Robin Anderson详细的逐步算法。 我试了一下它工作正常。 但是,在我可以在生产中测试它之前,我想用你运行我的代码。 我做对了吗? var httpRequest; var globalurl; function makeRequest(url) { globalurl = url; /* my custom script that retrieves original page without formatting (just data, no templates) */ finalurl = ‘/content.php?fname=’ + url ; if(window.XMLHttpRequest){httpRequest=new XMLHttpRequest}else if(window.ActiveXObject){try{httpRequest=new ActiveXObject(“Msxml2.XMLHTTP”)}catch(e){try{httpRequest=new ActiveXObject(“Microsoft.XMLHTTP”)}catch(e){}}} /* if no html5 support, just load the page without […]

使用jquery ajax删除表中的记录

我正在学习j查询Ajax事件。我已经使用j查询Ajax在php中插入并显示记录但是我无法删除记录我已经编写了代码但是它不能正常工作而且我不希望表再次加载。请帮助 TableName:登录 列:id,用户名,消息 comment.php $(document).ready(function(e) { function showComment(){ $.ajax({ type:”post”, url:”process2.php”, data:”action=showcomment”, success:function(data){ $(“#flash”).html(data); } }); } showComment(); //Insert records $(“#Submit”).click(function(){ if($(“:text”).val().length==0) { // $(this).next().html(“Field needs filling”); $(“:text”).after(‘Field cannot be empty’); //return false; success = false; } else { var name=$(“#name”).val(); var message=$(“#message”).val(); $.ajax({ type:”post”, url:”process2.php”, data:”name=”+name+”&message=”+message+”&action=addcomment”, success:function(data){ showComment(); } }); } }); $(‘.delete’).click(function(e){ e.stopPropagation(); […]