Question: I'm unable to download a file stream from a web server using CasperJS:

* a form is posted to a url
* url returns a file stream

So far I have validated that the correct form values are posted.

```
var casper = require('casper').create({
    verbose: true, 
    logLevel: 'debug',
    viewportSize: {width: 1440, height: 800},
    pageSettings: {
        userName: '****',
        password: '****',
        webSecurityEnabled: false
    },
    waitTimeout: 200000
});

casper.start("***");

casper.then(function() {
    var exportForm = this.evaluate(function() {
        return $("#export_pdf_form").serialize();
    });

    var exportAction = this.evaluate(function() {
        return $("#export_pdf_form").attr('action');
    });

    var url, file;
    url = '***' + exportAction; (eg. https://webserver/export)
    file = "export.pdf";
    casper.page.settings.webSecurityEnabled = false;
    casper.download(url, fs.workingDirectory + '/' + file, "POST", exportForm);
});

```

Casper error "Unfortunately casperjs cannot make cross domain ajax requests" followed by "XMLHttpRequest Exception 101". After searching it states that settings the web security variable to false should make this work...but it doesn't. Anything else I should look into?

casperjs - v1.1.1
phantomjs - v2.0.0

Answer: 
Turns out nothing is wrong with my code, simply updating PhantomJS from 2.0.0 to 2.1.1 has solved the issue.
There are a lot of AJAX cross-domain and same-origin security policy material written out there, take a look. As far as I know, there are only two alternatives to the one John proposed (setting up a proxy on the server side): 

**1. Using W3C CORS standard technique and HTTP headers.** 

<https://en.wikipedia.org/wiki/Cross-origin_resource_sharing>

**2. JSONP mechanism.**

<https://en.wikipedia.org/wiki/JSONP>

I really don´t know if it is the real problem you are experiencing, but I hope this is of good help to you.