Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with passing data to multiple pages in code igniter for JQuery
    primarykey
    data
    text
    <p>Currently my team and I are working with Code Igniter 1.7.3 and we are not capable of using code igniter 2.0 with our project.</p> <p>Anyway,</p> <p>I made several php files in which one main files uses JQuery to load the other files inside a certain div in the main file. It goes something like this for example (They are both in the views folder in CI)</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="&lt;?php echo base_url().''?&gt;public/scripts/jquery-1.4.4.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#insert-activity").load("&lt;?php echo base_url().''?&gt;system/application/views/bio.php"); }); &lt;/script&gt; &lt;title&gt;Title&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="insert-activity"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now, it loads perfectly. The problem is the controller loads the profile view</p> <pre><code>&lt;?php class UserProfile extends Controller { function UserProfile() { parent::Controller(); } function index() { $this-&gt;load-&gt;library('DX_Auth'); $this-&gt;load-&gt;helper('url'); $this-&gt;load-&gt;helper('form'); $this-&gt;load-&gt;model('userprofile_m'); $userID = $this-&gt;dx_auth-&gt;get_user_id(); $friend_ids = $this-&gt;userprofile_m-&gt;get_friends_ids($userID); $data['interest'] = $this-&gt;userprofile_m-&gt;get_user_intersts($userID); //$data['broadcasts'] = $this-&gt;userprofile_m-&gt;get_broadcasts($userID); $data['friendID'] = $friend_ids; //$data['friendsBroadcasts'] = $this-&gt;userprofile_m-&gt;get_friends_broadcasts($userID,$friend_ids); $this-&gt;load-&gt;view('profile', $data); } ?&gt; </code></pre> <p>The problem here is that I want some of the data retrieved to go to bio.php because profile.php will load the bio.php in the div.</p> <p>And everytime I click on the get bio link I want it to retrieve the information again and put it in bio.php while JQuery loads bio.php in profile.php</p> <p>Here is bio.php just in case</p> <pre><code>&lt;!-- PHP should insert the user's bio here --&gt; &lt;div id="activity-header" class="background"&gt; &lt;!-- activity header start DO NOT MODIFY--&gt; &lt;h1&gt;Bio&lt;/h1&gt; &lt;/div&gt; &lt;!-- activity header end DO NOT MODIFY--&gt; &lt;div id="activity-feed"&gt; &lt;!-- activity div for JQuery DO NOT STYLE THIS DIV--&gt; &lt;div&gt; &lt;!-- name start --&gt; &lt;div&gt; &lt;p &lt;p class="special-p"&gt;Name:&lt;/p&gt; &lt;hr class="special-hr"&gt; &lt;/div&gt; &lt;p class="used-p"&gt;some guy&lt;/p&gt; &lt;/div&gt; &lt;!-- name end --&gt; &lt;div&gt; &lt;!-- description start --&gt; &lt;div&gt; &lt;p &lt;p class="special-p"&gt;Description:&lt;/p&gt; &lt;hr&gt; &lt;/div&gt; &lt;p class="used-p"&gt;I don't like talking about myself... I'm emo .. for some reason&lt;/p&gt; &lt;/div&gt; &lt;!-- description end --&gt; &lt;div&gt; &lt;!-- interests start --&gt; &lt;div&gt; &lt;p class="special-p"&gt;Interests:&lt;/p&gt; &lt;hr class="special-hr2"&gt; &lt;/div&gt; &lt;p class="used-p"&gt;I am interested in:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;something&lt;/li&gt; &lt;li&gt;Food&lt;/li&gt; &lt;li&gt;Travel&lt;/li&gt; &lt;li&gt;Fishing&lt;/li&gt; &lt;li&gt;Pokemon&lt;/li&gt; &lt;li&gt;More Pokemon&lt;/li&gt; &lt;li&gt;POKEMOOONN!!!!&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;!-- interests start --&gt; &lt;/div&gt; &lt;!-- activity div for JQuery --&gt; </code></pre> <p>This is the code that @kevtrout taught me. Still, the page wont load inside the div</p> <p>this is the function bio inside the controller userProfile</p> <pre><code>function bio(){ $this-&gt;load-&gt;library('DX_Auth'); $this-&gt;load-&gt;helper('url'); $this-&gt;load-&gt;helper('form'); $this-&gt;load-&gt;model('userprofile_m'); $userID = $this-&gt;dx_auth-&gt;get_user_id(); $friend_ids = $this-&gt;userprofile_m-&gt;get_friends_ids($userID); $data['interest'] = $this-&gt;userprofile_m-&gt;get_user_intersts($userID); //$data['broadcasts'] = $this-&gt;userprofile_m-&gt;get_broadcasts($userID); $data['friendID'] = $friend_ids; //$data['friendsBroadcasts'] = $this-&gt;userprofile_m-&gt;get_friends_broadcasts($userID,$friend_ids); $bio_view = $this-&gt;load-&gt;view('bio',$data,true); return $bio_view; } </code></pre> <p>And this is the JQuery inside the view profile.php that wants to load thw view bio.php and send the data to .. This is immediatly done after the $(document).ready</p> <pre><code>$.post("&lt;?php echo site_url('userProfile/bio');?&gt;",{user_id: 777},function(){ $("#insert-activity").html(data); },html); </code></pre>
    singulars
    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.
 

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