Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with jQuery getJSON using local files in Chrome
    text
    copied!<p>I have a <a href="http://issues.tauren.com/testjson/index.html" rel="noreferrer">very simple test page</a> that uses XHR requests with jQuery's $.getJSON and $.ajax methods. The same page works in some situations and not in others. Specificially, it doesn't work in Chrome on Ubuntu.</p> <p>I'm testing on Ubuntu 9.10 with Chrome 5.0.342.7 beta and Mac OSX 10.6.2 with Chrome 5.0.307.9 beta.</p> <ul> <li>It works correctly when files are installed on a web server from both Ubuntu/Chrome and Mac/Chrome (<a href="http://issues.tauren.com/testjson/index.html" rel="noreferrer">try it out here</a>).</li> <li>It works correctly when files are installed on local hard drive in Mac/Chrome (accessed with file:///...).</li> <li>It <strong>FAILS</strong> when files are installed on local hard drive in Ubuntu/Chrome (access with file:///...).</li> </ul> <p>The small set of 3 files can be downloaded in a tar/gzip file from here: <a href="http://issues.tauren.com/testjson/testjson.tgz" rel="noreferrer">http://issues.tauren.com/testjson/testjson.tgz</a></p> <p>When it works, the Chrome console will say:</p> <pre><code>XHR finished loading: "http://issues.tauren.com/testjson/data.json". index.html:16Using getJSON index.html:21 Object result: "success" __proto__: Object index.html:22success XHR finished loading: "http://issues.tauren.com/testjson/data.json". index.html:29Using ajax with json dataType index.html:34 Object result: "success" __proto__: Object index.html:35success XHR finished loading: "http://issues.tauren.com/testjson/data.json". index.html:46Using ajax with text dataType index.html:51{"result":"success"} index.html:52undefined </code></pre> <p>When it doesn't work, the Chrome console will show this:</p> <pre><code>index.html:16Using getJSON index.html:21null index.html:22Uncaught TypeError: Cannot read property 'result' of null index.html:29Using ajax with json dataType index.html:34null index.html:35Uncaught TypeError: Cannot read property 'result' of null index.html:46Using ajax with text dataType index.html:51 index.html:52undefined </code></pre> <p>Notice that it doesn't even show the XHR requests, although the success handler is run. I swear this was working previously in Ubuntu/Chrome, and am worried something got messed up. I already uninstalled and reinstalled Chrome, but that didn't help.</p> <p>Can someone try it out locally on your Ubuntu system and tell me if you have any troubles? Note that it seems to be working fine in Firefox.</p>
 

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