的index.html
<div class='wrapper'>
<p>JSON will be received in 3 seconds</p>
<ul id='post'></ul>
</div>
external.js
new Request.JSON({
url: '/echo/json/',
data: {
json: JSON.encode({
text: 'some text',
array: [1, 2, 'three'],
object: {
par1: 'another text',
par2: [3, 2, 'one'],
par3: {}
}
}),
delay: 3
},
onSuccess: function(response) {
show_response(response, $('post'));
}
}).send();
show_response = function(obj, result) {
$H(obj).each(function(v, k) {
new Element('li', {
text: k + ': ' + v
}).inject(result);
});
result.highlight();
};
CSS
body {
font-family: Helvetica, Sans, Arial;
}
p, ul {
padding: 10px;
}
ul {
margin: 5px;
border: 2px dashed #999;
}
Click here demo
嘗試[FileReader](https://developer.mozilla.org/en/docs/Web/API/FileReader)對象。這將節省您不得不上傳文件 –
你可以找到你在這裏回答[如何閱讀外部本地JSON文件在JavaScript](http://stackoverflow.com/questions/19706046/how-to-read-an-external -local-json-file-in-javascript) – eGhoul
你使用什麼數據庫系統?您無法訪問僅基於客戶端的基於服務器的數據庫javascript – Marcus