Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:58:58+00:00 2026-06-07T14:58:58+00:00

Firstly sorry, I’m a really big beginner. I ran into a problem that I

  • 0

Firstly sorry, I’m a really big beginner.

I ran into a problem that I can’t really solve, i am building a facebook-like wall. and after the post is sent, I would like the results to append to a div, but I’m totally lost.

The problem is that it sends perfectly, but not shows the results

Here is my code

html

<?php foreach($stream_posts as $sp): ?>
    <div id="sp_<?php echo $sp->sid; ?>" class="row stream-posts">
        <div class="span1 stream-thumb">
            <ul class="thumbnails">
              <li>
                <a href="#" class="thumbnail">
                  <img src="http://placehold.it/60x60" alt="">
                </a>
              </li>
            </ul>
        </div>  
        <div class="span5 stream-content">
            <a href="#" class="author"><?php echo $sp->first_name ." ". $sp->last_name; ?></a>
            <p>
                <?php echo nl2br($sp->text); ?>
            </p>
        </div>

    </div>
    <?php endforeach; ?>

jQuery

$('.stream-form').on('submit', function(){
        var streamData = $(this).serialize();
        $.ajax({
            url: "<?php echo base_url(); ?>stream/insert_stream",
            type: "POST",
            data: streamData,
            dataType: "json",
            success: function(stream) {

                if(stream.error == 0)
                {
                    $('.stream-text').val("");
                    $('.stream-posts').append().text(stream.text);


                }   
            }
        });
        return false;
    });

In this jQuery code it appends all of it and breaks the div, i would like to show the new post what was submitted

Model

    function add_stream()
    {

        $data = array(
            'added_by' => $this->session->userdata('user_id'),
            'text' => $this->input->post('stream_text')
        );

        $this->db->insert('pf_stream', $data);


    }

function load_stream_post()
{
    $this->db->select('*');
        $this->db->from('pf_stream');
        $this->db->join('pf_users', 'pf_users.id = pf_stream.added_by');
        $this->db->order_by('pf_stream.sid', 'DESC');
        $this->db->limit(1);
        $query = $this->db->get();

        if($query->num_rows() > 0)
        {   
            foreach($query->result() as $row)
            {
                $sdata[] = $row;
            }
        return $sdata;  
        }

}
    // this is for the view
    function select_stream()
    {
        $this->db->select('*');
        $this->db->from('pf_stream');
        $this->db->join('pf_users', 'pf_users.id = pf_stream.added_by');
        $this->db->order_by('pf_stream.sid', 'DESC');
        $this->db->limit(5);
        $query = $this->db->get();

        if($query->num_rows() > 0)
        {   
            foreach($query->result() as $row)
            {
                $data[] = $row;
            }
        return $data;   
        }
    }

Controller

 public function index()
   {
        $this->load->view('partials/header');
        $data['stream_posts'] = $this->stream_model->select_stream();
           $this->load->view('stream_view', $data);
        $this->load->view('partials/footer');
   }

    function insert_stream()
    {
        $this->form_validation->set_rules('stream_text', 'Üzenet', 'trim|required|xss_clean');

        if($this->form_validation->run() == false)
        {
            $stream = array('error' => 1);
        } else {
            $this->stream_model->add_stream();
            $data['stream_result'] = $this->stream_model->load_stream_post();
            $stream = array(
               'error' => 0, 
               'sid' => $data['stream_result'][0]->sid,
               'text' => $data['stream_result'][0]->text,
               'author' => $data['stream_result'][0]->first_name . " " . $data['stream_result'][0]->last_name,
            );
        }
        echo json_encode($stream);
    }

Could someone please give me a hint what am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:59:01+00:00Added an answer on June 7, 2026 at 2:59 pm

    I think the problem is, here

    $('.stream-posts').append().text(stream.text);
    

    This should be

    $('.stream-posts').append(stream.text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, everyone: Firstly, sorry that my Flow description is long winded, but I think
Firstly, I would like to say that I don't mean the full path, what
Firstly, sorry for my English. I'm Brazilian guy that is improving yet. I want
Firstly - sorry for my English.. I've inherited a rather big project which uses
Firstly, i am sorry if the title does not properly describe my problem, but
Firstly I would like to accept that it is a homework question , but
Firstly, sorry for the difficult question title, but I can't think of anything better.
Firstly sorry if this is a common question but I couldn't find anything on
Firstly sorry for the long piece of code pasted below. This is my first
Firstly, sorry for my English (I'm from China). By reading this article( how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.