【发布时间】:2011-08-14 08:58:47
【问题描述】:
我在codeigniter中有以下视图-说edit_res_view-
<html>
<table>
<? foreach ($list as $key => $value): ?>
<tr><td><?= $key ?> :</td><td><input type="text" name='<?= $key ?>' size="25" value='<?php echo $value; ?>'/></td></tr>
<? endforeach; ?>
<tr><td colspan="2"><center><input type="submit" id="submit" size="40" value="SAVE" />
</table>
现在我在另一个视图中有另一个 jquery 函数,它从这个表单的 name 属性中获取值作为 POST 数据发送到另一个函数 -
$("#submit").live("click",function(){
$.ajax({
url: "http://localhost/codeigniter_local/index.php/manage_resources/doupdate_des",
type:"POST",
data:"d_id="+$("[name='d_id']").val()+
"&cpu_brand="+$("[name='cpu_brand']").val()+
"&processor="+$("[name='processor']").val()+
"&ram="+$("[name='ram']").val()+
"&hdd="+$("[name='hdd']").val()+
"&mac_id_wired="+$("[name='mac_id_wired']").val()+
"&mac_id_wireless="+$("[name='mac_id_wireless']").val()+
"&os="+$("[name='os']").val()+
"&os_license_no="+$("[name='os_license_no']").val()+
"&monitor_sno="+$("[name='monitor_sno']").val()+
"&keyboard_sno="+$("[name='keyboard_sno']").val()+
"&mouse_sno="+$("[name='mouse_sno']").val()+
"&sno="+$("[name='sno']").val()+
"&date_of_purchase="+$("[name='date_of_purchase']").val()+
"&warranty="+$("[name='warranty']").val()+
"&comments="+$("[name='comments']").val(),
success:function(html){
oTable.fnReloadAjax('http://localhost/codeigniter_local/index.php/manage_resources/json/1');
alert("Done !");
$("#form1").dialog("close");
},
ERROR: function(html){
alert(html);
}
});
} );//for submit
现在的问题是我想循环遍历 jquery 函数的“data:”属性的值,而不是像上面所做的那样对其进行硬编码。
该怎么做呢? (顺便说一句,$list 数组通过我的控制器作为参数传递给 edit_res_view)。
【问题讨论】:
标签: php codeigniter jquery-plugins jquery