Note that there are some explanatory texts on larger screens.

plurals
  1. POXMLHttpRequest access file in Public Dropbox
    primarykey
    data
    text
    <p>I'm building a quick website; because of its nature I can afford to host it in my Dropbox public folder. I'm trying to read some text files using XMLHttpRequest:</p> <pre><code>function getParameters() { var oRequest = new XMLHttpRequest(); var sURL = "http://dl.dropbox.com/u/7828009/Relay%20Fundraising%20Site/parameters.txt"; // var sURL = "file:///parameters.txt"; oRequest.open("GET",sURL,false); oRequest.onreadystatechange = function (oEvent) { if (oRequest.readyState === 4) { if (oRequest.status === 200) { console.log(oRequest.responseText) } else { console.log("Error", oRequest.statusText); } } }; oRequest.setRequestHeader("User-Agent",navigator.userAgent); try { oRequest.send(null) } catch (err) { alert(err); } if (oRequest.status==200) alert(oRequest.responseText); else alert("Error executing XMLHttpRequest call!"); } </code></pre> <p>I'm getting an XMLHttpRequest 101 error in the send() line and I have no idea how to resolve this. The exact error is </p> <pre><code>XMLHttpRequest cannot load http://dl.dropbox.com/u/7828009/Relay%20Fundraising%20Site/parameters.txt. Origin null is not allowed by Access-Control-Allow-Origin. </code></pre> <p>Can I do anything to fix this, or is it because of Dropbox themselves?</p> <p><hr /> <strike> <strong>Update</strong> I've tried loading the file from the dropbox URL directly. </p> <pre><code>http://dl.dropbox.com/u/7828009/Relay%20Fundraising%20Site/main.htm </code></pre> <p>New error is now</p> <pre><code>XMLHttpRequest cannot load http://www.javascripter.net/faq/requested_file.htm. Origin http://dl.dropbox.com is not allowed by Access-Control-Allow-Origin. </code></pre> <p>What can I do about this?</strike></p> <p><hr /> <strong>Update 2:</strong> D'oh moment…I had left in a test URL to see if it was a Dropbox issue. It linked to an external file. Fixing that fixed my issue. </p> <p>The principal problem was running the file off the local copy. Running from the Dropbox public URL fixed the issue. Thanks <a href="https://stackoverflow.com/a/10375507/472768">Quentin</a>, for indirectly leading me to the answer.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload