您现在的位置:首页 >> 前端 >> 内容

通过ajax得到数据,显示http://localhost:8081/项目名/[object%20Object]404(NotFound)错误。

时间:2017/8/2 10:15:56 点击:

  核心提示:今天在使用easyui-datagrid 中的toolbar,通过ajax得到数据时,出现https://localhost:8080/项目名/[object%20Object] 404 (Not F...

今天在使用easyui-datagrid 中的toolbar,通过ajax得到数据时,出现https://localhost:8080/项目名/[object%20Object] 404 (Not Found) 错误。

toolbar: [{
               id: 'btnAdd',
               text: '添加',
               iconCls: 'icon-add',
               handler: function () {
                   $.get({
                       url:"/rz/MyServlet?method=fun",
                       });
};
}]

折腾了一个小时,不论是get还是post方法都尝试了,还是不行,最后将get|post修改成ajax,并添加type属性,就正常了。

toolbar: [{
               id: 'btnAdd',
               text: '添加',
               iconCls: 'icon-add',
               handler: function () {
                   $.ajax({
type:”get”,
                        url:"/rz/MyServlet?method=fun",
                       });
};
}]

有人说,出现标题中的问题的原因是jquery包版本太低。
  解决方法:
  1、将.post改为使用.ajax;
  2、使用较高的jquery包版本。

Tags:通过 过A AJ JA 
作者:网络 来源:lxhuang_14