Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your comments to @icchanbobot you stated that you are trying to use a controller to get bio information from the db and return it to the jquery script but it is not working. I'm offering the following to try and help. Let me know if this is the approach you are pursuing or if this is obvious to you and there is something else making the process difficult.</p> <p>In my scripts, I follow the following outline when the jquery retrieves database info and injects it into the page. </p> <pre><code>$.post( "&lt;?php echo site_url('controller_x/get_bio');?&gt;", {user_id: userID}, function(data){ $('#insert-activity").html(data); }, html ); </code></pre> <p>Controller_x function get_bio() interacts with your db to pull the data out and load the view. Using the <a href="http://codeigniter.com/user_guide/libraries/loader.html" rel="nofollow">third parameter</a> of <code>$this-&gt;load-&gt;view();</code>, I return the view html as a string and assign it to a variable, then return the variable to the <a href="http://api.jquery.com/jQuery.post/" rel="nofollow">jquery post()</a> call.</p> <pre><code>class Controller_x extends Controller(){ function get_bio(){ $user_id = $this-&gt;input-&gt;post('user_id'); $this-&gt;load-&gt;model('bio_model'); $data['bio'] = $this-&gt;bio_model-&gt;get_bio($user_id); $bio_view = $this-&gt;load-&gt;view('bio',$data,true); return $bio_view; } } </code></pre> <p>the callback function in $.post() above takes the data that was returned and injects it in the named div. the 'html' tells the script what type of data to expect (html, json). I believe you can get away leaving it out, but not sure without testing.</p> <p>Hope this clarifies that you are either on the right track, or provides a missing detail.</p> <p>Good luck.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload