Javascript evalJSON不是一个函数
下面是我的代码Javascript evalJSON不是一个函数,javascript,jquery,Javascript,Jquery,下面是我的代码 $("document").ready(function () { var dataName = new Array(); $.get('<%=request.getContextPath()%>/empBox/ajaxToGetCodes.do', function (responseText) { var JSONcustomers = $.evalJSON(responseText); var total = JS
$("document").ready(function () {
var dataName = new Array();
$.get('<%=request.getContextPath()%>/empBox/ajaxToGetCodes.do', function (responseText) {
var JSONcustomers = $.evalJSON(responseText);
var total = JSONcustomers["arrayObj1"].length;
var index = 0;
});
$(“文档”).ready(函数(){
var dataName=新数组();
$.get('/empBox/ajaxToGetCodes.do',函数(responseText){
var JSONcustomers=$.evalJSON(responseText);
var total=JSONcustomers[“arrayObj1”]。长度;
var指数=0;
});
虽然我得到了响应文本,但它无法将其转换为json。
给出以下错误
$。evalJSON不是函数。
我正在向它添加所有必需的库。
jquery-json.js
和jquery.js
有什么想法吗,有什么问题吗?是
$。parseJSON
…更多文本以满足30个字符的限制而不是手动解析JSON,为什么不简单地使用getJSON来为您实现这一点
阅读以下文档:我认为它是
$。parseJSON
如果你想使用evalJSON,这里有一个插件:谢谢大家
实际上,由于其他一些内部脚本问题,jquery json插件文件虽然在DOM中加载,但调用方法无法识别
所以我使用了$.getScript,现在我的代码如下所示
$.get('<%=request.getContextPath()%>/empBox/ajaxToGetCodes.do', function (responseText) {
$.getScript("<%=request.getContextPath()%>/web/include/js/jquery.json-2.2.min.js",
var JSONcustomers = $.evalJSON(responseText);
var total = JSONcustomers["arrayObj1"].length;
var index = 0;
});
});
$.get('/empBox/ajaxToGetCodes.do',函数(responseText){
$.getScript(“/web/include/js/jquery.json-2.2.min.js”,
var JSONcustomers=$.evalJSON(responseText);
var total=JSONcustomers[“arrayObj1”]。长度;
var指数=0;
});
});
这就解决了我的问题!!:)你先试试这个
$.get('/empBox/ajaxToGetCodes.do',函数(responseText){alert(responseText);}
检查返回的数据是否为有效格式,或是否返回^^