jquery 和 jeasyui 处理 datagrid 行单击,并读取 datagrid 行信息,提交后台,返回 json 并解析:
(后台代码略)
通过向服务器 /path 提交,返回 json 格式字符串:
[{"id":"1","name":"aa","number":"bb","type":"cc","shortName":"dd","zipCode":"ee","fax":"ff","address":"","nature":"","founded":"1900-01-01 00:00:00.0","region":"","corporation":"","industry":"","linkman1":"","telephone1":"","position1":"","linkman2":"","telephone2":"","position2":"","enterpriseProfile":""}]
并通过 $.parseJSON(data) 解析
$(document).ready(function() { $("#dataGrid").datagrid( { // 声明 datagrid 的 row 单击事件 onClickRow : function(index, row) { $.ajax( { method : "POST", url : "http://host/path", async : false, data : { // 向 url 提交 参数 id id : row.id } }).done(function(data) { // 得到返回信息 转换为 json 对象 var json = $.parseJSON(data); // 解析 json $.each(json, function(i, item) { alert(item.name); // 得到 json 的 name 信息 }); }); } }) })
有问题Q群讨论:236201801