admin管理员组文章数量:1420540
I am currently trying to parse a local JSON file on Webkit browsers and I am running into a couple issues.
var request = new XMLHttpRequest();
request.open('Get', 'file:///abc/test.json', false);
var test = JSON.parse(request.responseText);
This however doesn't seem to work in Webkit Browsers (I am only testing on Webkit Browsers such as Chromium on ubuntu).
Could someone please help me point out what I might be doing wrong? Thank you in advance!
Edit: I noticed a bunch of responses indicate it isn't possible to use Ajax. Is there anything else I can use such as JQuery or do this?
I am currently trying to parse a local JSON file on Webkit browsers and I am running into a couple issues.
var request = new XMLHttpRequest();
request.open('Get', 'file:///abc/test.json', false);
var test = JSON.parse(request.responseText);
This however doesn't seem to work in Webkit Browsers (I am only testing on Webkit Browsers such as Chromium on ubuntu).
Could someone please help me point out what I might be doing wrong? Thank you in advance!
Edit: I noticed a bunch of responses indicate it isn't possible to use Ajax. Is there anything else I can use such as JQuery or do this?
Share Improve this question edited Oct 11, 2011 at 18:57 Bilzac asked Oct 11, 2011 at 18:46 BilzacBilzac 5553 gold badges9 silver badges23 bronze badges2 Answers
Reset to default 3The problem is that webkit doesn't allow ajax requests to file:/// So you have to use a http server which serves the site and the ajax response.
Have you tried launching chrome with --allow-file-access-from-files
key?
Seems to be related with Problems with jQuery getJSON using local files in Chrome question and Local files doesn't load with Ajax bug report.
本文标签: Parse local JSON file with JavaScript in WebkitStack Overflow
版权声明:本文标题:Parse local JSON file with JavaScript in Webkit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745336568a2654065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论