简体   繁体   中英

How to upload JSON file to create Object in Javascript Runtime without changing server side script?

How to upload JSON file to create Object in Javascript Runtime without request/respond with server side script ?

I have found the way to do it

JSON file >> (Upload via PHP to) >> Javascript >> Object in Runtime

But I don't want to use the php How to do it by this way ?

JSON FILE >>>> (Upload directly to) >>>> Javascript >>>>Object in Runtime.

THANKS.

update:

I am trying to solve this problem by looking for new feature in HTML5 such as local storage, index eddb, websql, application cache.

Javascript runs on client side, and your json file is on server so you need to do it through server side script, you cannot access server side file from client side javascript.

If it is client side file you can read it using FileReader in javascript

   var reader = new FileReader();
   reader.onload = function() {
     console.log(this.result);            
   }
   reader.readAsText(file)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM