• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get JSON data in table - Codeigniter

#2
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) : ?>

  <?php if ($t == 'blabla') : ?>
     <p>You said blabla</p>
  <?php else : ?>
     <p>You said something else…</p>
  <?php endif; ?>
  
<?php endforeach; ?>

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.
Reply


Messages In This Thread
RE: How to get JSON data in table - Codeigniter - by Wouter60 - 09-07-2018, 03:36 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.