我收到控制台日志输出,在这一行显示 TypeError: treeObj.root is undefined
:var count = treeObj.root.length;
不确定原因或方式解决它吗?
$.ajax({
url: 'Content/data.txt',
dataType: 'text',
success: function (treeObj) {
var count = treeObj.root.length; //here
最佳答案
使用 dataType: 'text'
告诉 ajax 调用将来自服务器的答案视为纯字符串。尝试将其更改为 dataType: 'json'
关于javascript - TypeError Obj.root 是未定义的 ajax jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28822910/