首先,return的那个对象,对象的键加上引号吧,你这样会不会被解析成一个变量?console.log(data.length);
console.log(data.splice);
if(typeof data.length=="number"&&typeof data.splice=="function"){
console.log(totle);
return {total:data.length,rows:data};
}else{
return data;
}使用上面的代码,查看一下,具体哪一行出问题了。
return {total:data.length,rows:data};
这一行稍微改一下吧。
return {"total":data.length,"rows":data};改成这样再试试。
console.log(data.splice);
if(typeof data.length=="number"&&typeof data.splice=="function"){
console.log(totle);
return {total:data.length,rows:data};
}else{
return data;
}使用上面的代码,查看一下,具体哪一行出问题了。
return {total:data.length,rows:data};
这一行稍微改一下吧。
return {"total":data.length,"rows":data};改成这样再试试。
解决方案 »
- JSON.stringify格式化数组的问题
- 高手请进 帮个忙 如何实现动态创建BOX盒子模型 急在在线等。。。。
- 求教:如何用java script对一个平面图进行放大缩小,带有测距功能
- cj205 come in, if I want press key "M",then call a method
- 为什么用js实现年月日的select值增加失败
- 如何用JS在固定位置插入代码
- 如何让一个文本框只能输入数字?
- 怎样在下拉菜单onchangd时,显示不同个数的文本框
- 简单任务,快来完成啊………… 有奖赏的 100分哪……
- 请教:如何用javascript写空格?
- kindeditor无法显示数据
- 哪位亲有JS版的 slider控件啊 (滑动条)
if(typeof(data.length)=="number"&&data.length>0&&typeof(data.splice)=="function"){
return {total:data.length,rows:data};
}else{
return data;
}
},你这样改改试试 ,这是你写的吗 要是别人写好的插件不应该报错啊 是不是你的引包顺序有问题,现因jquery的核心基础包。
我是做后台的。人家让我改前台bug啊、、
loadFilter:function(data){
if(data == "" || data == null || data == undefined)
{
alert("数据为空!");
return;
}
if(typeof data.length=="number"&&typeof data.splice=="function"){
return {total:data.length,rows:data};
}else{
return data;
}
}
if(data == "" || data == null || data == undefined)
{
alert("数据为空!");
return;
}
if(typeof data.length=="number"&&typeof data.splice=="function"){
return {total:data.length,rows:data};
}else{
return data;
}
}
console.log();打印出来的数据,你看看加上上面那三个打印,打印出来的是什么,复制一下发出来。如果是undefined,或者在相应的地方报错,反正都复制出来,贴一下吧。
alert(typeof data)
alert(typeof data.splice)错误是报的找不到对象
第二个是undefined
if(data == "" || data == null || data == undefined)
{
alert(typeof data);
alert(typeof data.splice);
return;
}if(typeof data.length=="number"&&typeof data.splice=="function"){
return {total:data.length,rows:data};
}else{
return data;
}
},
只谈了一次object
alert(Object.prototype.toString().call(data));看看这个弹出的什么东西,弹出的格式一般是"[object Function]",这样类型的,这就表明data是一个函数
什么也没弹、提示 网页错误详细信息用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; BOIE9;ZHCN)
时间戳: Thu, 19 Dec 2013 02:32:28 UTC
消息: 对象不支持此属性或方法
行: 7903
字符: 3
代码: 0
URI: http://localhost:8080//easyUi/jquery.easyui.min.js
Object.prototype.toString.call(data)这个才是,多加了个括号。。
可以在你自己代码中,使用这个方法的地方,加个判断,if(data !== null){},把你调用这个方法的代码,放到这个判断之内。或者就是说,你获取到的data就是错误的,不是期望达到的,那就是提供这个data的代码有问题了。
不过要改的话,如果你是在做一个团队的项目的话,你又是新手的话,还是去问问带你的人就说,找到问题在哪了,问问能不能改,改了会不会影响其他地方的功能。团队的事,还是要多多了解一下,整个团队的工作流程是怎样的,尤其是代码的改写,还是要跟随一下团队的整体风格的好。先找到代码修改的地方,然后具体怎么改,去问问带你的师傅吧。