这是我的jQuery脚本
$("table#list").jqGrid({
url:'example.php',
datatype: 'json',
mtype: 'POST',
colNames:['ID', 'Position', 'Abrv', 'Department'],
colModel :[
{name:'id', index:'id', width:40, hidden: true, editrules:{edithidden:true}},
{name:'position', index:'position', width:300, editable: true, required: true},
{name:'abvr', index:'abvr', width:50, editable: true, required: true},
{name:'department', index:'department', editable: true, edittype: 'select', editoptions:{dataUrl: 'test2.php'}}
],
width: 600,
height: 250,
rownumbers: true,
pager: '#pager',
rowNum: 10,
rowList:[10,20],
sortname: 'id',
sortorder: 'ASC',
viewrecords: true,
gridview: true,
caption: 'Position',
loadError : function(xhr,st,err) {
$("#rsperror").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
},
editurl: 'insertDB.php'
});
insertDB.php
if($_POST['oper'] == 'add'){
$position = $_POST['position'];
$department = $_POST['department'];
$query = "INSERT INTO test_position VALUES ('', '$position', '$department')";
$run = mysql_query($query);
}
提交表单时没有任何反应。我的数据库同样不会更新。
答案 0 :(得分:0)
我忘了选择一个数据库。我在使用FireBug后发现了。