![]() |
How to get JSON data in table - Codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to get JSON data in table - Codeigniter (/showthread.php?tid=71626) |
How to get JSON data in table - Codeigniter - jaydevvara - 09-07-2018 [url=https://stackoverflow.com/questions/52217079/how-to-get-json-data-in-table-codeigniter/52217327?noredirect=1#][/url] Hello I want to display data on click without refresh page in codeigniter, I got data in JSON but how to display in table view, so here is my code so please help me. Here Is My Controller: Code: public function get_event_date() { Here Is My Model: Code: public function getallevent($start_event,$end_event) Code: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> RE: How to get JSON data in table - Codeigniter - Wouter60 - 09-07-2018 Use JSON.parse(data) in the success part of AJAX: Code: records = JSON.parse(data); A few remarks on php styling. If you mix php and html, the alternative syntax for control structures can be very helpful: PHP Code: <?php foreach($records as $record) : ?> In your page, you have the <tbody> inside the foreach structure. That's not necessary. Place it before the foreach, and the </tbody> after it. In stead of "<?php echo" you can use "<?=" in views. Makes it more compact and better to read. RE: How to get JSON data in table - Codeigniter - jaydevvara - 09-07-2018 (09-07-2018, 03:36 AM)Wouter60 Wrote: Use JSON.parse(data) in the success part of AJAX: RE: How to get JSON data in table - Codeigniter - jaydevvara - 09-07-2018 (09-07-2018, 03:53 AM)jaydevvara Wrote:(09-07-2018, 03:36 AM)Wouter60 Wrote: Use JSON.parse(data) in the success part of AJAX: i already added json in success part but i did not get in response in success part |