php - How to populate data from database through AJAX and display it in table format? -


<script type="text/javascript">    function select_std(){      var ali=$('#class_std').val();       $('#std_name').html('');      $.ajax({        url:"<?php echo base_url().'admin/test/'?>"+ali,        type:"get",               success:function(res){      $('#std_name').append(res);          }        });    }
 <select id="std_name" class="form-control">                                                              </select>

i have populated dropdown menu through ajax , works fine. however, want display in table format, how can this? have searched many sites in vain.

this rather broad question stack overflow, happy give pointers.

is server-side under control? if so, try returning json web server. so, rather returning single blob of html render directly, return array, each element can rendered per cell (and two-dimensional array can render rows). here how in jquery.

on server side, you'll need render data using json_encode(). first. if want, can hard-wire data on server-side before changing read database. example, started:

echo json_encode([     ['cell_one' => 1, 'cell_two' => 2, ],     ['cell_one' => 3, 'cell_two' => 4, ] ]); 

of course, can use indexed arrays if prefer. if associative arrays, please change key names more suitable.

once have data, can plot in success handler using loop. try that, please?


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -