zoukankan      html  css  js  c++  java
  • 无刷新输出

    小纸条信息的无刷新输出主要应用是ajax技术;通过ajax技术调用指定的文件查询是否存在新的消息,并且将结果返回,通过div输出ajax中返回的查询结果;代码如下

    <script language="javascript">
    function show_counts(senders){ //通过show_counts()函数调用指定的文件统计最新信息
    xmlhttp=new XMLHttpRequest();//设置要执行的文件,并设置栏目标识 url='test.php?sender='+senders; // alert(url); // show_couonts.php?sender=tang xmlHttp.open("get",url, true);   xmlHttp.onreadystatechange = function(){ if(xmlHttp.readyState == 4){ tet = xmlHttp.responseText; show_counts11.innerHTML=tet; } } xmlHttp.send(null); } </script>

     数据处理代码

    <?php 
      $conn=@mysql_connect("localhost","root","");        //连接数据库服务器
      mysql_select_db("db_forum",$conn);                  //连接指定的数据库
      mysql_query("set names gb2312");                    //对数据库中的编码格式进行转换,避免出现中文乱码的问题
      $query=mysql_query("select * from tb_mail_box where tb_receiving_person='".$_GET["sender"]."' and tb_mail_type='1'"); 
      $myrow=mysql_num_rows($query);
      echo $myrow; 
    ?>
    

    显示页面

    <script language="javascript">
    	// 定时刷新,间隔1000毫秒执行一次show_counts()函数
    	setInterval("show_counts('<?php echo $_SESSION["tb_forum_user"];?>')",1000); 
    </script>
    
  • 相关阅读:
    shell 中的expect 用法
    Python下安装protobuf
    google protobuf 中的proto文件编写规则
    ubuntu 16.04 安装grpc
    python 常见的错误类型 和 继承关系
    倒排索引
    python 调用c函数
    python中的re模块,常用函数介绍
    leecode第二十二题(括号生成)
    leecode第十九题(删除链表的倒数第N个节点)
  • 原文地址:https://www.cnblogs.com/aten/p/9059618.html
Copyright © 2011-2022 走看看