0

I am using JavaScript to post an XML request to an online database. When I was testing the JavaScript, I used a single sample record which successfully posted. Now, I need to reference a separate XML file that has 6,000+ records (stored either locally or on a network drive).

I am trying to determine the best approach for this, but have been unsuccessful thus far. I have referenced other questions such as Javascript - read local text file, but I am getting an Access Denied error, most likely due to cross-domain requests (even though I have changed my Security settings).

Is there any way to accomplish this? My external XML file is simply the <root> and then the records, nothing more.

Community
  • 1
  • 1
CJK
  • 99
  • 7
  • 20
  • See https://developer.mozilla.org/en/docs/Web/API/File, if you put an `input type="file"` in your HTML document you can select a local file and then the browser exposes it to Javascript. – Martin Honnen Aug 22 '16 at 16:01
  • @MartinHonnen thank you for the response! This would require the user to select the file every time though, correct? I would like to reach a point where this JavaScript can run automatically at a designated frequency. – CJK Aug 22 '16 at 16:52
  • Without user interaction I don't think a browser will allow the file system access, unless you write a browser extension or the browser allows to to somehow grant privileges to the script. – Martin Honnen Aug 22 '16 at 17:32
  • @MartinHonnen do you think it'd be more plausible to upload the XML to the same site where the JavaScript HTML file is located? I am not quite sure what format to upload the XML (either .xml, .txt. or .htm) in order to read all of the records. – CJK Aug 22 '16 at 19:34

0 Answers0