0

Here i'm sending post data using xmlHttpRequest along with binary data. but xhr.send(formdata); giving error of invalid argument.

var formData = {};
formData.files= options[0].file;

    var bodyValues = options[0];
        delete bodyValues.file;

        formData.bodyData=bodyValues;

var xhr = new XMLHttpRequest();

        xhr.open('POST', config.javaServer+config.baseUrl+AccountNumber+"/upload/"+config.lowerClaimDocUplTs, true);
        xhr.setRequestHeader('claimNum',ClaimNumber);
        xhr.onload = function () {
            // do something to response
            console.log(this.responseText);
            console.log("success");
            var uploadRespo = $.parseJSON(this.responseText);
            if(uploadRespo.error){
                 console.log("error");
            }else if(uploadRespo.data.status=="200"){
                 console.log("success");
            }else{
                 console.log("error");
            }
        };
        xhr.onerror = function () {
            console.log("error upload");
                 console.log("error");
           alert("upload failed");
        };
        xhr.send(formData);
Naveen Asapu
  • 39
  • 1
  • 7
  • `dfd.reject("400");` and `dfd.resolve(uploadRespo);` What are these? Looks like a promise but IE7 doesn't support promises... or really anything, it's an awful browser – Trevor Apr 13 '18 at 16:04
  • "xhr.send(formdata); giving error of invalid argument". What is `formdata`? This is the argument that is invalid. – gforce301 Apr 13 '18 at 16:06
  • `console.log(formData);` just before the send and see what your passing in – Trevor Apr 13 '18 at 16:07
  • yes your correct promise is also not working in ie7. since FormData is not supporting in IE7. i created object and sending as a body along with file – Naveen Asapu Apr 15 '18 at 14:50

0 Answers0