Uncaught TypeError: $(…).serializeJSON is not a function
ps:讲道理jquery.serializejson.min.js的引用绝对没问题,其他页面serializeJSON 也能用,就很尴尬 我怀疑是layui自带的jquery冲突了,最后心累放弃解决,直接用js方法。
getFormJson($("form")) --就这样吧 替代 $(form).serializeJSON()
function getFormJson(form) {
var o = {};
var a = $(form).serializeArray();
$.each(a, function () {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
}
有解决的朋友吗,望告知,所有页面都行,就它不能用
排错过程: 1、chrome调试的时候:这个$(“form”)里Prototype就是没有serializeJSON方法,引用没问题chrome都能直接打开这个jquery.serializejson.min.js文件
2、jquery.serializejson.min.js文件正确,因为其他页面能用serializeJSON这个方法,Prototype里也有这个函数serializeJSON(疑惑)
3、百度 自建了jquery方法$.fn.serializeObject 写在了该页面内置的js里面,还是引用不了,自此怀疑这个页面jquery和layui有冲突或者别的jquery问题
好文推荐
发表评论