-1
我有以下的html:閱讀與JavaScript .txt文件,並填寫一個陣列
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geomap']});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Country', 'Money', ''],
['US', 80.21, 'United States']
['JP', 10.01, 'Japan']
...
]);
var options = {};
var geomap = new google.visualization.GeoMap(document.getElementById('chart_div'));
geomap.draw(data, options);
};
</script>
</head>
<body>
<div id="chart_div" style="width: 750px; height: 550px;"></div>
</body>
</html>
我需要直接讀取具有下列內容的.txt文件:
['Country', 'Money', ''],
['US', 80.21, 'United States']
['JP', 10.01, 'Japan']
,並填寫這裏使用的陣列:
var data = google.visualization.arrayToDataTable([...]);
我怎樣才能使這是JavaScript?
謝謝 丹尼爾
你嘗試過什麼嗎?你在某個時候被卡住了嗎? – 2013-04-10 15:04:07
問題是我如何直接讀取.txt文件並填充數組? – danibraga2 2013-04-10 16:15:24