function loadFile(path){ $.ajax({ url: path,dataType: 'json',async:false,success: function(data) { return eval('('+data+')'); } }); }
必须应该要导入js包,类似:<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
调用:
function readText(){ return loadFile("../channelFile/channels.txt"); }原文链接:https://www.f2er.com/ajax/163826.html