dousha1394 2015-08-03 09:59
浏览 91
已采纳

点击后再次阅读更多按钮

i have a readmore link that allows people to read more posts once it has been clicked, what i don't want is the button showing again and i also don't want the whole post to show again, i just want the remaining posts to add to the previous that the reader has read or being reading just as its done on facebook page when you click seemore link.

Thanks

$(function(){
$(".readMore").click(function(event){
     event.preventDefault();
    var link = $(this).attr('href');
    var dataString = 'link='+ link;
    $.ajax({
        type : "POST",
        url: "readmore-post.php",
        data: dataString,
        cache : false,
        success: function(html){
        $(".read_more").before(html);
                
        }
        
    });
    });
    });
this is the html part 

<?php echo substr($post,0,250); ?>..
<?php
if(strlen($post)>250)
{
echo"<a href='$postID' style='font-size:0.8em;' class='readMore'>readmore</a>  </br>";
}
?>
<div class="read_more"></div>
                    

this is the php part

<?php
include('../config/connect.php');
$read_id = $_POST['link'];
$srm = "SELECT * FROM page_timeline WHERE timelineID='$read_id' ORDER BY timelineID DESC";
$sre = $db->query($srm);
while($rowr = $sre->fetch_array())
{
$postID = $rowr['timelineID'];
$post = $rowr['post'];
}
echo "<p>".$post."</p>";
?>   
                        

</div>
  • 写回答

1条回答 默认 最新

  • dos71253 2015-08-03 10:09
    关注

    Try this and see inline comments

    $(function(){
    $(".readMore").click(function(event){
            event.preventDefault();
            var that=$(this);
            var link = $(this).attr('href');
            var dataString = 'link='+ link;
            $.ajax({
                type : "POST",
                url: "readmore-post.php",
                data: dataString,
                cache : false,
                success: function(html){
                    $(".read_more").empty().append(html); 
                    //clear all the contents and append new one to .read_more div 
                    that.hide(); //hide the button on successful load
                },
            });
        });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!