1

I try to add new lines to the end of current. I think problem is here

 $("#main_content").append(data);

it take new data all html (html + css) and add to curent data what is already shown

Maybe is it possible to take only from data ?

or replece data with new and put the current to the first position?

js

$(document).ready(function(){
    var num_messages = num_rows;
    var loaded_messages = 0;

    $("#more_button").click(function(){
        loaded_messages += 10;
        $.get(base_url + "twitterpagination/get_messages/" + loaded_messages, function(data){
        $("#main_content").append(data);

        });

        if(loaded_messages >= num_messages - 10)
        {
        $("#more_button").hide();
        //alert('hide');
        }
    });
})

html

<body>
<div id="main_content">
<?php
foreach($latest_messages as $message)
{
    echo $message->username . ' - ' . $message->message . '<br />';
}
?>
</div>
<div id="more_button">
more
</div>
</body>

result

        user - message 1
        user - message 2
        user - message 3
        user - message 4
        user - message 5
        user - message 6
        user - message 7
        user - message 8
        user - message 9
        user - message 10
0

1 Answer 1

1

You should use jquery text

http://api.jquery.com/text/

This should do it.

Sign up to request clarification or add additional context in comments.

10 Comments

do you mean append(data).text() ?
append(data) return me full html page. Still do not know how to get from (date) only id="main_content" ?
maybe you can give (write) a small example. Sorry for asking
@ViktorsGolubevs sure , let me understand your problem better
@Viktors , is that ajax call in your control?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.