代码
jQuery(function(){
$.ajax({
url: "/cjTest/worker_list.do",
type:'post',
dataType: "json",
success: function(data){
$.each(data.user, function(i) {
$("#workerlistTbl").html(data.workerJson);
});
}
});
}); table:<table id="workerlistTbl" style="width:450px;height:auto"
title="Editable DataGrid" iconCls="icon-edit" singleSelect="true"
idField="name" >
<tr>
<th field="name" width="80" >员工姓名</th>
<th field="department" width="100" formatter="productFormatter" editor="{type:'combobox',options:{valueField:'department',textField:'name',data:departments,required:true}}">所属部门</th>
<th field="sex" width="80" formatter="sexeach" editor="{type:'combobox',options:{valueField:'sexid',textField:'sex',data:sexsel,required:true}}" >员工性别</th>
<th field="entrydate" width="60" align="center" >入职时间</th>
</tr>
</table>
jQuery(function(){
$.ajax({
url: "/cjTest/worker_list.do",
type:'post',
dataType: "json",
success: function(data){
$.each(data.user, function(i) {
$("#workerlistTbl").html(data.workerJson);
});
}
});
}); table:<table id="workerlistTbl" style="width:450px;height:auto"
title="Editable DataGrid" iconCls="icon-edit" singleSelect="true"
idField="name" >
<tr>
<th field="name" width="80" >员工姓名</th>
<th field="department" width="100" formatter="productFormatter" editor="{type:'combobox',options:{valueField:'department',textField:'name',data:departments,required:true}}">所属部门</th>
<th field="sex" width="80" formatter="sexeach" editor="{type:'combobox',options:{valueField:'sexid',textField:'sex',data:sexsel,required:true}}" >员工性别</th>
<th field="entrydate" width="60" align="center" >入职时间</th>
</tr>
</table>
url="/SZGW/RTDServlet"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="rid" width="60">ID</th>
<th field="did" width="60">DID</th>
<th field="value" width="60">Value</th>
<th field="date" width="120">Time</th>
<th field="deviceid" width="60">Deviceid</th>
</tr>
</thead>
</table>
直接url对应就好了
JSONArray jsonArray = JSONArray.fromObject(workerlist);
JSONObject jsonObject = new JSONObject();
jsonObject.put("workerJson", jsonArray);
response.getWriter().write(jsonObject.toString());
只写 url 不行吧 ,怎么知道获取的是workerJson?