日期:2014-05-16 浏览次数:20373 次
$("#send").click(function() { var msg = $("#msg").val(); var user; if($("#user").val()==""){ user="游客"; }else{ user = $("#user").val(); } $.ajax({ type : "post", url : "chat_add", data : { msg : msg, user : user }, dataType : "json", success : function(jsonStr) { var data = eval(jsonStr); $ .each( data, function(i, n) { msgchat += n.time + " " + n.user + ":" + "<br>" + " " + n.msg + "<br>"; }); document .getElementById('showMsg').innerHTML = msgchat; document .getElementById('showMsg').scrollTop = document .getElementById('showMsg').scrollHeight; } }); $("#msg").val("");//清空 });
public String add() throws Exception { chat.setMsg(msg); chat.setUser(user); this.chatService.addMsg(chat); this.msglist=this.chatService.searchMsg(chat);//查询 outputJson(msglist); return null; }
$("#msg").val("");//清空 return false;///////////增加这句阻止表单提交