zoukankan      html  css  js  c++  java
  • php ajax dom---动态增加

    js代码

    <script type="text/javascript">
    $(document).ready(function(){
      $("#talk_send").click(function(){
        
        var ask = $("#ask").val();
        
        $.ajax({
                 type: "GET",
                 url: "action.php",
                 data: {value:ask},
                 dataType: "json",
                 success: function(data){
                            $('#jp-container').append('<div class="talk_recordbox"><div class="user"><img src="images/thumbs/11.jpg"/>刘韵</div><div class="talk_recordtextbg">&nbsp;</div><div class="talk_recordtext"><h3 >我的问题是:<label class="huida">'+data['ask']+'</label></h3><span class="talk_time">'+data['time']+'</span></div></div>');
    
                            $('#jp-container').append('<div class="talk_recordboxme"><div class="user"><img src="images/thumbs/15.jpg"/>王玉山</div><div class="talk_recordtextbg">&nbsp;</div><div class="talk_recordtext"><h3>对方的回答是:<label class="tiwen">123</label></h3><span class="talk_time">'+data['time']+'</span></div></div>');
            
                            $('#talk_record').scrollTop($('#talk_record')[0].scrollHeight);
                          }
             });
       
    
    
        
      });
    });
    </script>

    后台程序

    <?php
    header("Content-Type: text/html;charset=utf-8");
    $ask = $_REQUEST['value'];
    $time = date("Y-m-d H:i:s");
    echo "{"time":"".$time."","ask":"".$ask.""}";
    ?>
  • 相关阅读:
    加密文件夹 | 彻底隐藏文件夹
    Swing的概述
    Java SE练习题——求奇数
    多线程有什么用?
    Robot的使用
    基础的Servlet
    Angular Resolver 学习
    GoLang 学习
    Angular Material 控件学习
    Angular 学习小记
  • 原文地址:https://www.cnblogs.com/hellowzd/p/5338354.html
Copyright © 2011-2022 走看看