码迷,mamicode.com
首页 > Web开发 > 详细

php ajax dom---动态增加

时间:2016-03-30 19:25:39      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:

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."\"}";
?>

 

php ajax dom---动态增加

标签:

原文地址:http://www.cnblogs.com/hellowzd/p/5338354.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!