XMLHttpRequest file upload not working in IE11

后端 未结 1 1901
抹茶落季
抹茶落季 2021-01-23 23:41

Hi I have the following JS on my page. It is working fine on chrome and firefox. but its not working on Internet Explorer 11. I\'m a salesforce developer and I don\'t know much

相关标签:
1条回答
  • 2021-01-24 00:28

    In the line:

    var xhr = new XMLHttpRequest();
    

    Change for:

    var xhr = new ActiveXObject('Msxml2.XMLHTTP');
    

    Now, your file upload work only in Internet Explorer 11.

    Maybe, for you file upload to work in all navigator's (that support XMLHTTPRequest), try this:

    if('ActiveXObject' in window){
       return new ActiveXObject('Msxml2.XMLHTTP');
    }else{
       return new XMLHttpRequest();
    }
    

    Source: http://www.purplesquirrels.com.au/2014/06/local-ajax-calls-ie11/.

    0 讨论(0)
提交回复
热议问题