我需要将ajax请求结果放到现有表中,怎么做?这是我的ajax请求
$("input#order").click(function(){
var idmenu = $("#idmenu").val();
var menu = $("#idmenu :selected").text();
var qty = $("#qty").val();
$.ajax({
type :'POST',
url :'<?php echo base_url();?>index.php/welcome/process',
data :'idmenu='+idmenu+'&menu='+menu+'&qty='+qty,
beforeSend:function(){
$("#result").html('<img src="<?php echo base_url();?>assets/loading.gif"/>');
},
success:function(result){
//result is json format
}
});
});
这是来自ajax请求的json格式
{"itemname":"product1","qty":"3","prices":"4500"}
这是我的表格格式
<table class="list-order">
<tr>
<th class="order">order</th>
<th class="qty">qty</th>
<th class="pice">price</th>
</tr>
//how to append ajax result here
<tr>
<td colspan="2"></td>
<td align="right"><input type="submit" size="25" id="process" value="Proses"/></td>
</tr>
</table>
我想附加ajax的结果
<tr>
<td></td>
<td></td>
<td></td>
</tr>
并且不在标签内,例如
<tr>
<td>result is not here</td>
</tr>
最终结果看起来像这样
<table class="list-order">
<tr>
<th class="order">order</th>
<th class="qty">qty</th>
<th class="pice">price</th>
</tr>
<!-- result look like this -->
<tr>
<td>product1</td>
<td>2</td>
</td>4500</td>
</tr>
<!-- end result-->
<tr>
<td colspan="2"></td>
<td align="right"><input type="submit" size="25" id="process" value="Proses"/></td>
</tr>
</table>