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 7554263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:17:29+00:00 2026-05-30T11:17:29+00:00

I m using codeigniter and would like to grab some user info with ajax.

  • 0

I m using codeigniter and would like to grab some user info with ajax. This is what I have but it s not working

In the view I have a defined variable:

<script type="text/javascript">
    var end_user = "<? echo $user_id; ?>";
</script>
<div id="tabs6"></div>

js file:

function get_experience()
{
$.post(base_url + "index.php/home/get_experience", { user : end_user }, function(data) {
           if (data.status == 'ok')
           {
$("div#tabs6").html(data);
           }
        else
           { //nothing }
           }, "json");
}

            get_experience();

controller:

public function get_experience()
    {
            $this->load->model('experience_model');
            $end_user = $this->input->post('user');

            $one_exp = $this->experience_model->one_exp($end_user);

            if ($one_exp->num_rows() > 0)
            {
                    $one_exp_html = '<ul>';
                    foreach($one_exp->result() as $exp)
                    {
                            $one_exp_html .= '<li>';
                            $one_exp_html .= $exp->experience;
                            $one_exp_html .= '</li>';
                    }
                    $one_exp_html .= '</ul>';
                    $result = array('status' => 'ok', 'content' => $one_exp_html);
                    return json_encode($result);
                    exit();
            }
            else
            {
                    $result = array('status' => 'ok', 'content' => 'nothing here');
                    return json_encode($result);
                    exit();
            }

    }

model:

function one_exp($end_user)
    {
            $query_str = "SELECT experience FROM exp WHERE user_id = ?";
            $query = $this->db->query($query_str, $end_user);
    }
  • 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-05-30T11:17:31+00:00Added an answer on May 30, 2026 at 11:17 am

    You need to add return $query to your one_exp method.

    EDIT

    You’re setting user_id in your view, but then using end_user in your javascript function get_experience().

    Also, since it’s json you’ll need to change the html fill to

    $("div#tabs6").html(data.content);
    

    For more debugging add an alert to your callback (right before if (data.status == 'ok') add alert(data);)

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

Sidebar

Related Questions

I'm using CodeIgniter 2+ and would like to Audit all $this->db->query($sql); calls. All of
I am using my codeigniter success message for this question. I would like it
I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,
I'm trying to send an email using codeigniter, and would like the message to
I would like to store images in my mySQL database using the CodeIgniter PHP
Using codeigniter and oci8 for a project. $this->db->insert_id(); would would perfect for getting the
I am using the following code to send email in codeigniter and would like
i'm trying to create a multilevel list using codeigniter. the list would look like:
Currently working on a bespoke ecommerce application using Codeigniter. I have a products table
I am using CodeIgniter, and in one of my models I would like 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.