Welcome Guest, Not a member yet? Register   Sign In
How to get JSON data in table - Codeigniter
#2

(This post was last modified: 09-07-2018, 03:53 AM by Wouter60.)

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



Theme © iAndrew 2016 - Forum software by © MyBB