ajax监视已经获取到数据,返回却获取不到数据,请大神指点!!!
var gridManager = null;
var activeDialog = null;
var $grid;
$(function () {
//菜单条
$("#topmenu").ligerMenuBar({ items: [
//{ text: '文件', menu: menu1 },
{text: '导出', menu: menu2 },
{ text: '表格风格', menu: menu3 }
]
});
//搜索
$("#searchbtn").ligerButton({ click: function () {
searchGrid();
}
}).setValue('查询');
//表格
$grid = $("#prigrid").ligerGrid({
columns: [
{ display: '公司编码', name: 'COMPANY_CODE', width: 120 },
{ display: '公司名称', name: 'COMPANY_NAME', width: 120 },
{ display: '公司简介', name: 'COMPANY_PROFILE', width: 120 },
{ display: '企业文化', name: 'ENTERPRISE_CULTURE', width: 80 },
{ display: '公司历程', name: 'FLYING_DRAGON_UNDERGO', width: 120 },
{ display: '公司公告', name: 'COMPANY_PROCLAMATION', width: 220 },
{ display: '公司网站', name: 'URL', width: 60, type: 'int' },
{ display: '预留字段1', name: 'FIELD1', width: 160 },
{ display: '预留字段2', name: 'FIELD2', width: 80 },
{ display: '预留字段3', name: 'FIELD3', width: 80 }
],
dataAction: 'server', sortName: 'COMPANY_CODE',
width: '100%', height: '100%', pageSize: 15, rownumbers: true,
//应用灰色表头
cssClass: 'l-grid-gray', heightDiff: -6,
toolbar: { items: [
{ text: '增加', id: 'add', click: itemclick, icon: 'add' }, { line: true },
{ text: '修改', id: 'modify', click: itemclick, icon: 'modify' }, { line: true },
{ text: '删除', id: 'delete', click: itemclick, icon: 'delete' }
]
}
});
$.ajax({
type: "GET",
contentType: "application/json",
url: "CompanyServer.ashx?action=GETDATA",
dataType: 'json',
success: function (result) {
debugger;
$grid.set({ data: result });
}
});
gridManager = $("#prigrid").ligerGetGridManager();
$("#pageloading").hide();
});
以上为源码,,
调用一般处理程序,已经获得了数据但在
$.ajax({
type: "GET",
contentType: "application/json",
url: "CompanyServer.ashx?action=GETDATA",
dataType: 'json',
success: function (result) {
debugger;
$grid.set({ data: result });
}
});
却获取不了数据,请大神帮我检查下,那块出了问题,这个问题虐的我欲仙欲死!!!! Ajax
[解决办法]
程序里
$.ajax({
type: "GET",
contentType: "application/json",
url: "CompanyServer.ashx?action=GETDATA",
dataType: 'json',
success: function (result) {//result 变量怎么赋值?
debugger;
$grid.set({ data: result });
}
});
$.ajax()返回变量js调试看返回变量值
[解决办法]
持续关注
[解决办法]
$.ajax({
type: "GET",
contentType: "application/json",
url: "CompanyServer.ashx?action=GETDATA",
dataType: 'json',
success: function (result) {
debugger;//这里是干嘛~~~~
$grid.set({ data: result });
}
});
说起来应该不是没有获取到数据,你先讲dataType修改成text,再alert出result值,就知道有没有值了.应该是你返回的json数据格式,跟ligerGrid需要绑定的json数据格式不一样.
json也有许多中格式的.认真看看ligerGrid的demo,就会发现
[解决办法]
那要看看result的格式是否正确了?
dataType: 'json',有严格的格式要求
------解决方案--------------------
看代码是没啥问题。
在 success: function (result) { 后第一行加一个 alert();
看看有没有执行。
用chrome(其他的也行),看看有没有js脚本错误。