Note that there are some explanatory texts on larger screens.

plurals
  1. POReturn table row as a HTML code via ajax and add in table
    primarykey
    data
    text
    <p>I am coding an application which fetches the data from data base on the basis of <code>id</code> given and return row in table, it is a bar code billing module, it <code>.append</code> the row as the barcode string given, but the problem which I am facing, when I am returning table <code>row as a HTML</code> code <code>&lt;tr&gt;..&lt;/tr&gt;</code>, via <code>ajax</code> I cannot see the new table row printed(added) on my table. </p> <p>Here is my view:</p> <pre><code> &lt;table class="table table-bordered"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;S No.&lt;/th&gt; &lt;th&gt;Particular&lt;/th&gt; &lt;th&gt;QTY&lt;/th&gt; &lt;th&gt;Cost&lt;/th&gt; &lt;th&gt;Discount&lt;/th&gt; &lt;th&gt;Discard&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody class="todo_list"&gt; &lt;?php echo $list;?&gt; &lt;input type="hidden" name="bill_ref" value="&lt;?php echo $bill_ref ?&gt;"/&gt; &lt;input type="hidden" name="date" value="&lt;?php echo $date ?&gt;"/&gt; &lt;/tbody&gt; &lt;?php echo $total_bill; ?&gt; &lt;div id="bill_tbl"&gt; &lt;--!MY NEW ROW SUPPOSED TO BE ADDED HERE!--&gt; &lt;/div&gt; &lt;/table&gt; </code></pre> <p>My ajax JS:</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#c_id").change(function(){ var send_data=$("#c_id").val(); $.ajax({ type:"post", url:"billing_table", dataType: "html", data:"i_id_post="+send_data, success:function(data){ $("#bill_tbl")..after(data); } }); }); }); &lt;/script&gt; </code></pre> <p>and my controller (for testing purpose i am operating my DB part in controller i am sorry for this):</p> <pre><code>public function billing_table() { $b_barcodestring=$this-&gt;input-&gt;post('b_barcodestring'); $i_id=$this-&gt;input-&gt;post('i_id_post'); if($i_id==''&amp;&amp; $b_barcodestring!='') { echo $b_barcodestring; } else if($b_barcodestring=='' &amp;&amp; $i_id!='' ) { //i want to print sumple this dummy row in my table echo '&lt;tr &gt;&lt;input type="hidden" name="counter[]" value="ssss"&gt;&lt;/tr&gt;&lt;tr &gt;&lt;td&gt;+counter+&lt;/td&gt; &lt;input type="hidden" name="particular[]" value="Greting Card" &gt;&lt;td&gt;'.$i_id.'&lt;/td&gt; &lt;td&gt; &lt;input type="number" name="qty[]" value="+qty_cal+"&gt;&lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="cost[]" value="150" &gt;150&lt;/td&gt; &lt;td&gt;&lt;input type="hidden" name="discount[]" value="N/A"&gt;N/A&lt;/input&gt;&lt;/td&gt; &lt;td &gt;&lt;button class="btn btn-danger"&gt;&lt;i class="icon-remove icon-white"&gt;&lt;/i&gt;Delete&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;'; } $this-&gt;output-&gt;enable_profiler(TRUE); } </code></pre> <p>Here is the <a href="http://jsfiddle.net/mxcWm/82" rel="nofollow">FIDDLE</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload