Export to GitHub

phantomjs - issue #291

AJAX calls in the file system do not work in phantomjs


Posted on Nov 24, 2011 by Happy Elephant

1.3

What steps will reproduce the problem? 1. Try to run a script that makes an AJAX call to a resource in the file system (i.e. $.getScript('file://C:/script.js')) 2. It will fail to run

I used binary PhantomJS in windows.

This is the same behavior as webkit browsers like Google Chrome, for google chrome you need to run it with the parameter --allow-file-access-from-files to make it run but there is no such parameter for phantomjs (http://stackoverflow.com/questions/4270999/google-chrome-allow-file-access-from-files-disabled-for-chrome-beta-8). This is needed for us to run javascript unit tests as part of the build in the local file system.

Comment #1

Posted on Feb 22, 2012 by Quick Hippo

I'm voting to set by default to true --allow-file-access-from-files flag. There can be also new config property: --allow-file-access-from-files for executing phantomjs.

Comment #2

Posted on Mar 28, 2012 by Quick Rabbit

Does the new --web-security command line option solve this issue?

Comment #3

Posted on Jun 21, 2012 by Helpful Giraffe

I've build the whole test suite of rasterizeHTML.js around loading local files through AJAX. PhantomJS 1.5. is pretty happy with loading everything so far. However I make sure that files I reference are in a directory below the file I am opening.

Comment #4

Posted on Aug 25, 2012 by Happy Dog

The --web-security=no switch doesn't work for me. I'm trying to use a proxy object with extjs to access local .json files.

Comment #5

Posted on Aug 25, 2012 by Happy Dog

Please see my question on SO here: http://stackoverflow.com/questions/11933044/using-phantomjs-to-make-ajax-calls-using-extjs-proxy-on-local-file.

Comment #6

Posted on Mar 16, 2013 by Happy Horse

Closing. This issue has been moved to GitHub: https://github.com/ariya/phantomjs/issues/10291

Status: Migrated

Labels:
Type-Defect Priority-Medium