ajax 同步加载调用不到

ajax 同步加载调用不到

我在使用easyui-datagrid碰到的问题

 { title: '用户组', field: 'gid', width: 300, formatter: function (value) {                     //alert(groups);                     for (var i = 0; i < groups.length; i++) {                         if (groups[i].gid == value) return groups[i].groupname;                     }                     return value;                 }, editor: { type: 'combobox', options: { valueField: 'gid',                     textField: 'groupname',                     //url: '/Areas/Manager/Handler/WebStat/AdminList.ashx?classa=grouplist'                     data: groups                 }                 }                 }

在该列中我需要调用groups变量的json数据
在js中预先赋值
 var groups = [{ "gid": "5", "groupname": "三级" },         { "gid": "4", "groupname": "二级" },         { "gid": "2", "groupname": "一级" },         { "gid": "1", "groupname": "管理员"}];

然后datagrid调用 没有问题 可以正常显示datagrid
但是我在
 $(function () {                         $.ajax({                             cache: false,                             async: false,                             type: "POST",                             url: "/Areas/Manager/Handler/WebStat/AdminList.ashx?classa=grouplist",                             success: function (data) {                                 groups = data;                             }                          });             list();//调用datagrid         });

页面加载中预先调用json赋值给groups,然后再加载datagird
问题出现了,datagrid不显示,也就是加载没成功
alert(groups);我在列里弹出了一下 显示groups是正常赋值了
返回数据有问题吧。。浏览器直接访问/Areas/Manager/Handler/WebStat/AdminList.ashx?classa=grouplist看输出的内容和直接js赋值的一样没有。。

一样加红色的内容试试
 $.ajax({
                            cache: false,
                            async: false,
                            type: "POST",dataType:'json',////////
                            url: "/Areas/Manager/Handler/WebStat/AdminList.ashx?classa=grouplist",
                            success: function (data) {
                                groups = data;
                            }
                        });

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有