CodeIgniter Forums
Need help in refreshing data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Need help in refreshing data (/thread-249.html)



Need help in refreshing data - kudoj - 11-14-2014

Hi All, I'm new with codeigniter and currently trying to build online shop website.

I'm facing problem with refreshing data after calling 'load->view()'.

So i have product list (admin_product_list.php) in my admin panel let say the data is like this:

id|name|qty
1|shoes|3
2|shirt|4
3|hat|5

and now i update the first row (shoes), change its qty to 9, submit it, so in database qty has been change to 9.

after that, i press a link for back to product list page
Code:
<a href="<?= site_url()?>admin_controller/admin_anchor_product_list" > &lt;&lt; Back to Product Panel</a>
which calls this controller :

PHP Code:
public function admin_anchor_product_list()
    {
        if(
$this->session->userdata('login_status') != 'admin'){echo 'whoops, what are u trying for? u need admin access to this';exit;}
        
$product $this->product_model->get_product_all();
        
$saleitem $this->product_model->get_sale_item_all();
        
$data = array();
        if(isset(
$product))
        {
            
$data['product'] = $product->result();
            
$data['saleitem'] = $saleitem;
        }
        
$this->load->view('admin_product_list',$data);
    } 

the problem is, data in product list (admin_product_list) is not refreshed :
id|name|qty
1|shoes|3
2|shirt|4
3|hat|5

i have to press f5 (refresh) so the page is refreshed and show me new data:
id|name|qty
1|shoes|9
2|shirt|4
3|hat|5

How to show new data after calling 'load->view()' without pressing f5 to refresh page?
I read some people using redirect, but in this case i dont know if it is possible to use redirect.
Please help me to solve this problem. Thank you Smile


RE: Need help in refreshing data - sv3tli0 - 11-14-2014

load->view must be at the end of your Controller Method.
There is no such thing as refreshing content without F5 in PHP ..
If you need HTML update after page is loaded you are talking about Javascript.


RE: Need help in refreshing data - Chroma - 11-14-2014

Do you have page caching turned on?


RE: Need help in refreshing data - Khadeer - 12-01-2015

I m Getting same problem. I have Used redirect('pagename', 'refresh'); but did nt give the thing i needed. I need to refresh page every time i do any thing like edit delete to see the changes. Thanx for your help in advance


RE: Need help in refreshing data - Wouter60 - 12-01-2015

My advice is to learn AJAX. If you already now how to use Jquery, it isn't very difficult. AJAX, in combination with a Codeigniter controller, is very powerful!


RE: Need help in refreshing data - Khadeer - 12-02-2015

Thanx for your advice. just give me any sample code so that i get to know what is the solution. Thank You.