获取外部文件.
你必须使用xmlHttpRequest.使用jQuery(包括jQuery库)简化为.
You will need to run the HTML file in a local server like Apache,
browsers like Chrome doesnt allow xmlHttp for file:// urls.
$.ajax({
type: "GET",
url: "words.txt",
dataType: "text",
success: parseTxt
});
使用成功回调来处理数据
parseTxt是读取和传递文件内容的函数.然后,您可以在parseTxt中编写代码以将文本处理为字符串.
function parseTxt(text){
var rows=text.split('\n');
//for each row
//cols=rows[i].split(',');
}
这应该足以让你开始我猜.
您甚至可以使用iframe通过Shadow Wizard尝试上述问题的答案.
如图所示,可以在没有jQuery的情况下生成RAW XMLHttpRequest