php教程视频教程全集(解析用php写简单消息推送及源码示例)

wufei123 发布于 2024-01-30 阅读(124)

  入口代码index.html        反ajax推送    .send{color:#555;text-align:left;}

  .require{color:blue;text-align:right;}  .content_box{text-align:center;margin:20px;  border:1pxsolid#ddd;padding:20px;}

php教程视频教程全集(解析用php写简单消息推送及源码示例)

          消息框

  1  2    

  发送  连接

          $(function(){  //发送消息

  $(#btn_send).click(function(){  varsend_text=$(#send_text).val();  if(send_text.length<=0){  $(#error_tip).html(不能输入空值);

  }else{  send(send_text);  }  });  //按回车键发送消息  $(#send_text).on(keyup,function(e){  if(e.keyCode==13){

  $(#btn_send).trigger(click);  }  });  //建立通讯链接  $(#btn_link).click(function(){  connect();  var_this=$(this);

  _this.attr(disabled,true);  _this.html(已连接);  });  });  //建立通讯连接函数  functionconnect(){  $(#content_box_title).html($(#username).val()+的消息窗口);

  $.ajax({  data:{user:$(#username).val()},  url:ajaxPush.php,  type:get,  timeout:0,  dataType:json,

  success:function(data){  $(#content_box).append(+data.msg+);  connect();  }

  });  }  //发送消息函数  functionsend(massege){  varuser=$(#username).val();  $.getJSON(write.php,{msg:massege,user:user},function(data){

  if(data.sf){  $(#content_box).append(+massege+);  $(#send_text).val();  }else{

  $(#error_tip).html(输入保存错误!);  }  });  }        ajax处理输入write.php  

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

河南中青旅行社综合资讯 奇遇综合资讯 盛世蓟州综合资讯 综合资讯 游戏百科综合资讯 新闻84300