我想发布' application / x-www-form-urlencoded'的数据内容类型。在IE8上通过javascript

时间:2016-07-12 10:58:01

标签: javascript internet-explorer-8 cors

我想做的只有一个是POST。

在IE10 +中,我可以像

一样
  const xhr = new XMLHttpRequest()

  xhr.onreadystatechange = function (event) {
    if (xhr.readyState === 4) {
      const statusCode = xhr.status
      const responseText = xhr.responseText

      if (responseValidator(statusCode, responseText)) {
        if (successCallback) successCallback(xhr)
      } else {
        /** error :  blah blah */
      }
    }
  }

  xhr.open('POST', url, true)

  xhr.timeout = timeoutMillis 

  xhr.ontimeout = function (event) {
   /** blah blah */
  }

  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')

  xhr.withCredentials = true 

  xhr.send(data)

//仅用于发布

但是,在IE8,9中只有XDomainRequest,它不支持CORS和HeadSetting。

有谁解决了这个问题?

0 个答案:

没有答案