21

I am making a synchronous ajax call ( ajax settings async: false ). This works well.

Now I'm trying to write an automated test for this in phantomJS and I'm getting this error

NETWORK_ERR: XMLHttpRequest Exception 101 

I checked my service logs and it seems like service is not getting any request.

sublime
  • 4,013
  • 9
  • 53
  • 92

1 Answers1

27

Try disabling the web security by using the command-line option --web-security=no when running your script. (phantomjs --web-security=no yourscript.js)

From the PhantomJS reference (http://phantomjs.org/api/command-line.html):

"--web-security=[true|false] enables web security and forbids cross-domain XHR (default is true). Also accepted: [yes|no]

johnnycrab
  • 977
  • 8
  • 8
  • Correct work for me, that's not problem of `XMLHttpRequest`. – Huy Nguyen Aug 22 '16 at 08:44
  • 1
    awesome.. thanks.. it was driving me crazy. I love phantom but they really need to work on their exception handling... give better explanations of what happened – carinlynchin Mar 31 '17 at 21:42
  • I'm using phantomjs as a driver for xrayjs for web scraping and this causes it to just run forever and not output anything. – Urasquirrel Jul 23 '18 at 16:20