我需要将一个jax请求结果放到现有的表,它是如何做到的?这里是我的Ajax请求追加jQuery的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请求
{"itemname":"product1","qty":"3","prices":"4500"}
这里的JSON格式是我的表格式
<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>
a ND未在标签内,像
<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>
我已经编辑了我的问题,json格式也有 – 2012-07-18 10:01:50
@wenkhairu您还可以提供正是你想要的结果HTML看起来像?每条信息有一个“”或一个“”? – 2012-07-18 10:04:41
我编辑了我的问题Anthony – 2012-07-18 10:08:16