下边的代码里:运行后div里的内容不刷新,分析了一下觉得逻辑没问题,不知道是不是有些细节没处理。多谢了!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index.html</title>

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

<style>
body {margin:0; padding:250px; border:1px solid; padding: 5px; overflow:auto;}
#messageWindow {height:250px; border: 1px solid; padding:5px; overflow:auto}
#wrapper {margin:auto:width:438px}
</style>

<script type="text/javascript" src="scripts/jquery-1.3.1.js"></script>

<script type="text/javascript">
$(function(){
timestamp = 0;
updateMsg();
$("#chatform").submit(function(){
$.post("backend.jsp", {
message:$("#msg").val(),
name:$("#author").val(),
action:"postmsg",
time:timestamp
}, function(xml,textStatus){
$("#msg").val("");
addMessages(xml);
});
return false;
});
});

function updateMsg() {
$.post("list.jsp",{time:timestamp},function(xml,textStatus) {
$("#loading").remove();
addMessages(xml);
});

setTimeout('updateMsg()',4000);
}

function addMessages(xml) {
//alert($("status",xml).text());
if($("status",xml).text()=="2") return;
timestamp = $("time",xml).text();

$("message",xml).each(function(){
var author = $("author",this).text();
var content = $("text",this).text();
var htmlcode = "<strong>"+author+"</strong>:"+content+"<br/>";

$("#messagewindow").prepend(htmlcode);
});
}
</script>
  </head>
  
  <body>
<div id="wrapper">
<p id="messagewindow"><span id="loading">加载中...</span></p>
<form id="chatform">
姓名:<input type="text" id="author" size="50"/><br/>
内容:<input type="text" id="msg" size="50"/><br/>
<input type="submit" value="发送"/><br/>
</form>
</div>
  </body>
</html>