2014-09-06 63 views

回答

0

您可以使用AJAX。因为JavaScript是太难用了AJAX(Internet Explorer的是有罪的),你可以使用JQuery的

$.ajax({ 
    type: "GET", 
    url: "file.txt",     // or path to file 
    success: function(content) { 
     // parse the content (content is the file content) 
    }, 
    error: function() { 
     console.log('error'); 
    } 
}); 

其中解析的内容是这样的:

var lines = content.split('\n'); 
for (var i = 0 ; i < lines.length ; i++) { 
    // take index1, index2, value and store them in a 2d array (parse lines[i]) 
} 
+0

我没有站在索引1和索引2来自 – TheProWolfPcGames 2014-09-06 17:18:22

+0

一条线看起来像这样:'0,1:1'。这是'线[我]'。 只需将0作为“index1”,将1作为“index2”,将1作为值。提示:“分裂”。 – 2014-09-06 17:21:15

+0

谢谢我现在得到它 – TheProWolfPcGames 2014-09-06 17:25:37