I have a proxy that uploads a fire to the Amazon S3 Server. This proxy is made using NodeJS and my webpage is hosted on a Tomcat server. So to make a Xhr upload I had to use Nginx to solve the cross domain issues as the both servers are on the same machine.
But using Nginx has a lot of issues so my boss asked if I can do the same thing using a Cross Domain Policy. I've made it but that is some things that I'm not being able to do. Here is my code:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(e) {};
xhr.open('POST', self.basePath + '/upload' + file.name, true, null, null, null, true, true);
xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
xhr.setRequestHeader("Connection", "close");
xhr.sendAsBinary(file.getAsBinary());
This works on a Cross Domain Request reaching the Server with the file and returning the response, but when I try to set a progress event like these:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(e) {};
xhr.upload.onprogress = function(){console.info('on progress');};
xhr.open('POST', self.basePath + '/upload' + file.name, true, null, null, null, true, true);
xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
xhr.setRequestHeader("Connection", "close");
xhr.sendAsBinary(file.getAsBinary());
The Cross Domain Request isn't fired ( the request uses a "OPTIONS" method instead of POST and it never reaches the server ). But, as you may think, I need the progress event to show it to the user. Does anyone knows what is happening??
Ps: All of the codes above works perfectly on a "same domain" request. Ps2: I've tried xhr.onprogress but it is never fired ( on cross or same domain requests ) Ps3: I've tried on FF4+ and Chrome 12+
Thanks A LOT. Thiago
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)