2014-09-06 64 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