一款简约网页聊天室

<script>
function sxx() {
var Words = document.getElementById(“words”);
var TalkWords = document.getElementById(“talkwords”);
var TalkSub = document.getElementById(“talksub”);
var f = document.getElementById(“f”);
$.ajax({
url: ‘ajax/sxx.php’, //请求的url
type: ‘post’, //请求的方式
data: ”,
dataType: ‘json’,
error:function (data) {
alert(‘请求失败’);
},
success:function (data) {
var ii=data.user.length;
if(data.user.length<20){
var i1=0;
}else{
var i1=ii-20;
}
var stt=””;

for (i=i1; i< ii; i++) {
var t=data.user[i].t;
var n=data.user[i].n;
var x=data.user[i].x;
var name=getcookie(‘n’);
if(n==name){
st1='<div class=”btalk”><span id=”bsay”>’+t+n+’:’+x+'</span></div>’;

}else{
st1='<div class=”atalk”><span id=”asay”>’+t+n+’:’+x+'</span></div>’;
}
stt=stt+st1;
}
$(“#words”).html(stt);
Words.scrollTop = Words.scrollHeight;

点赞

发表评论