如何在Internet Explorer 7中使用xmlhttpRequest发送发布请求

时间:2018-04-13 16:00:53

标签: javascript internet-explorer xmlhttprequest internet-explorer-7 ie7.js

这里我使用xmlHttpRequest和二进制数据发送帖子数据。但是xhr.send(formdata);给出无效参数的错误。

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);

0 个答案:

没有答案