开发者

Problems with Chrome path

I am using jquery and 开发者_开发百科running a html file on my local machine (no server).

The following works on firefox but not on chrome:

$('#result').load('test.html');

It seem to be something wrong with the path.

Anyone know how to sort this out without having to add an absolute path please?

Thanks


Ajax requests cannot be sent cross-domain. On your local machine, every request is cross-domain to the browser, so no Ajax can be used at all. Chrome is a bit more strict than Firefox here. There is no solution, you will just have to upload it to a web server or install something like Apache on your local machine for testing purposes.


Typically, AJAX requests cannot be sent cross-domain, however, if you're just looking to access a local file, you could try enabling one of Chrome's secret flags. Specifically:

--allow-file-access-from-files

With any luck, you should be able to get things working by changing your chrome shortcut to the following:

chrome.exe --allow-file-access-from-files

I'm not sure if that flag is enabled in all builds of Chrome (I am presently running chromium 10), but it definitely works: I've been using it to enable file-save access in TiddlyWiki.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜