Welcome Guest, Not a member yet? Register   Sign In
[JS Help]refresh a div
#12

[eluser]garymardell[/eluser]
How i would do it: (might not be the best way, never generated tables)

I would have my controller that gets all the data for that page, both the full page and the table obviously.

Then i would have a view that is designed to render the table. And a view of two to render the whole page and include the table view.

With the javascript i would send a variable back to the controller via post or get called something like is_ajax = true.

In the controller if the post/get variable is set to true then i would just return the table view created before and if it was not set then return the whole page. (There other ways to check if the request came from ajax but i cannot remember off the top of my head).


This way it means you have one controller and if you lay it out well enough by putting the getting the table information near the top as it will be required either way it will be faster.

Code:
// get table data as it is required whether ajax or not
// this example is purely for demonstration of logic not actual use.
if($this->input->post('is_ajax')) {
    $this->load->view("table_view", $data);

}
else {
    // get additional data

    // load the entire site and use the table view to avoid repetition.
    
    $this->load->view("header", $data);
    $this->load->view("table_view", $data);
    $this->load->view("footer", $data);

}


Messages In This Thread
[JS Help]refresh a div - by El Forum - 10-22-2009, 03:37 AM
[JS Help]refresh a div - by El Forum - 10-22-2009, 04:21 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 02:23 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 03:13 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 03:27 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 05:22 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 05:58 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 10:07 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 11:27 AM
[JS Help]refresh a div - by El Forum - 10-23-2009, 01:27 PM
[JS Help]refresh a div - by El Forum - 10-26-2009, 03:38 AM
[JS Help]refresh a div - by El Forum - 10-26-2009, 03:57 AM
[JS Help]refresh a div - by El Forum - 10-27-2009, 03:54 AM
[JS Help]refresh a div - by El Forum - 10-28-2009, 04:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB