CodeIgniter Forums
Need help w/ Dynamic content and passing data around - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: Need help w/ Dynamic content and passing data around (/thread-40983.html)



Need help w/ Dynamic content and passing data around - El Forum - 04-25-2011

[eluser]Unknown[/eluser]
I've been using CI now for around 2 months and I really like its structure, but I'm having a hard time finding out how to do certain, "more involved" things. What I have set up is a page, and I would like dynamic content to be displayed depending on what the user does on the page.

Here's the problem I'm having...

I want to load a view, lets say '/members/' and never go to other pages, but rather, change the content on the page depending on the what the user is doing.

** I want to load the view once using function index()
** User does some processing and hits 'submit'
** Then pass info back to the controller, to pass to the model for Database querying
** Pass the info back to the controller, who then passes it to the view.
** The view then loads the new content from the controller WITHOUT reloading or going to '/members/view_info'

I've been told to look into Jquery and JSON. I have JQUERY so I can dynamically change content, but the problem I have is how to get the info BACK to the view w/o the reload. Especially when I'm returning an array of arrays, like EVENTS[event1, event 2, etc], where each event has a good amount on info associated with it.

The problem stems from someone else writing all the code that handles the information, but it must be passed to the view, like when it is passed into a view using: $this->load->view('member_view', $data);
because the page uses variables like "$rows" which are passed as $data['rows']

Once in the view I don't know of a way to "re-pass" information in that same format w/o doing a page reload. My sincerest apologies for the lengthy post, but I have been going crazy trying to understand all this and figure out a way to not have to rewrite all his work (there is a LOT).


Need help w/ Dynamic content and passing data around - El Forum - 04-25-2011

[eluser]toopay[/eluser]
[quote author="int21h" date="1303746218"]I've been told to look into Jquery and JSON.[/quote]
Look deeper ;-)
[quote author="int21h" date="1303746218"]The problem stems from someone else writing all the code that handles the information, but it must be passed to the view, like when it is passed into a view using: $this->load->view('member_view', $data);
because the page uses variables like "$rows" which are passed as $data['rows'][/quote]
The general scenario would be :
1. You have a js function, which make an ajax call to server.
2. You have separated controller function to handle the call, proccess it, then generates the data (that would be JSON).
3. The success function on your ajax call, will modify/manipulated your content by DOM mechanism.