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

  • SEARCH
  • Home
  • 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 6752559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:03:33+00:00 2026-05-26T13:03:33+00:00

Basically, I have a string of functions that load a set of blog entries

  • 0

Basically, I have a string of functions that load a set of blog entries to build the page. At the bottom of the page I have a link that initiates a jQuery Ajax to an Ajax controller that uses the exact same string of functions to load more blog entries with a different offset.

I have two queries initially in one of the functions. One that counts how many rows exist total, and the main function that returns the data for 10 or less rows called. I’m getting all of the data, except for the main blog entry data.

Here’s most of the code, I cut out everything else in the functions that isn’t relevant:

Main view controller

public function blog() {
    $this->load->helper('date');
    $this->load->model('blog_model');

    $result = $this->blog_model->process_uri(0);
    $this->load->view($result['view'],$result);
}

Ajax controller

public function blog_data() {
    $this->load->helper('date');
    $this->load->model('blog_model');

    //$offset = $this->input->post('offset');
    $data = $this->blog_model->process_uri(0);
    echo json_encode($data);
}

Model

public function process_uri($offset) {
    $result;
    $uri = $this->uri;

    // There's more this function, but I cut it out.
    $result = array('type' => 'list');

    return $this->blog_model->get_blog_data($result,$offset);
}

Where I think the problem lies

private function get_blog_data($data,$offset) {
    $return = array('type' => $data['type']);
    $limit;
    $select;

    if (false) {
    }
    else {
        $return['view'] = 'blog_view';

        $this->db->select('id');
        $r = $this->db->get('blog');
        $return['total'] = $r->num_rows() - ($offset + 10);
        $return['current'] = $offset + 10; // This returns

        $limit = 10;
        $select = 'blog.id,title,type,date,message,images';
        $this->db->order_by('blog.id','desc');
        if (isset($data['date'])) $this->db->like('date',$data['date'],'after');
    }

    $this->db->select($select);
    $this->db->from('blog');
    $this->db->join('blog_img','blog_img.id = blog.id','left');
    $this->db->limit($limit,$offset);

    // This does not return any data in the Ajax call.
    $return['entries'] = $this->blog_model->process_data($this->db->get());

    return $return;
}

private function process_data($data) {
    foreach($data->result() as $i => $row) {
        //Formats the data
    }
}

The return data I get in JavaScript is:

{"type":"list","view":"blog_view","total":5,"current":10,"entries":[]}

As you can see, even if I pass identical data through the Ajax controller, the entries array is still empty. I’m not too familiar with CodeIgniter, and especially using Ajax with it, so I would greatly appreciate if anyone could help with this, as it’s really killing me.

Also, I know the problem is not in the JavaScript code, because I tried adding some static data in the process_data function to see if it would show up and it does, hence that is the reason why I didn’t add the JavaScript code.

  • 1 1 Answer
  • 1 View
  • 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-05-26T13:03:33+00:00Added an answer on May 26, 2026 at 1:03 pm

    After some searching around I found the last_query codeigniter function which returns the last query, so I could see what was going wrong.

    $return['last'] = $this->db->last_query();
    

    And here’s the query that was being run through AJAX

    SELECT `blog`.`id`, `title`, `type`, `date`, `message`, `images`\nFROM (`blog`)\nLEFT JOIN `blog_img` ON `blog_img`.`id` = `blog`.`id`\nWHERE  `date`  LIKE 'blog\\_data%'\nORDER BY `blog`.`id` desc\nLIMIT 10"
    

    I was eventually able to find the problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these images that will load when I input a certain string of
I've got a requirement that is basically this. If I have a string of
I have two functions that do the basically same thing on two different classes....
Basically I have this string for example $str = 'По, своей 12' I need
Basically I have this string $str=word1 word2 word3; I need array( 'word1', 'word2', 'word3'
I basically have the following string in the format: A,B,C:D,E,F What I am trying
I have a String variable (basically an English sentence with an unspecified number of
I have a string which is basically a list of words delimited by commas.
I have the following data that basically I only need a few bits of
basically i have a folder with php scripts and then in that folder i

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.