Reputation: 831
I'm getting inconstant between Firefox and Chrome when sending an XLSX file with XMLHttpRequest as part of a multipart request. The XLSX file has images on the first page, date on the second. I am posting the request as so:
var fd = new FormData();
fd.append("attachFile", gel("attachFile").files[0]);
fd.append("sysparm_id", gel("sysparm_id").value);
fd.append("sysparm_target", gel("sysparm_target").value);
var xhr = new XMLHttpRequest();
xhr.open("POST", "my_processor.do");
xhr.send(fd);
Nothing fancy here. Whats interesting to me is that on the server side I can retrieve the file from the request no problem. However, on FireFox it does not send the file with the request.
I can't really see why having an image in the XLSX file would be an issue? The problem feels like it must be on the client side. I've tried multiple ways of retrieving the file from the MPP and all work on chrome, but not Firefox.
Upvotes: 1
Views: 535
Reputation: 68
The window is reloading before the success event is sent. You should be using an event listener like so:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { //Call a function when the state changes.
if(this.readyState == XMLHttpRequest.DONE && this.status == 200) {
window.location.reload();
return true;
}
For more information, please consult this documentation.
Upvotes: 1