Javascript IE:使用AJAX发送POST数据

Javascript IE:使用AJAX发送POST数据,javascript,ajax,internet-explorer,Javascript,Ajax,Internet Explorer,我正在用AJAX发送POST数据: const form = d.getElementById('form'); form.addEventListener('submit', SendData); function SendData(e) { e.preventDefault(); var data = e.target.getElementsByTagName('input')[0].value.trim(); var xhr = new XMLHttpReque

我正在用
AJAX
发送
POST
数据:

const form = d.getElementById('form');
form.addEventListener('submit', SendData);

function SendData(e) {
    e.preventDefault();
    var data = e.target.getElementsByTagName('input')[0].value.trim();

    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function(event){
        console.log(event.target.responseText);
    });

    xhr.addEventListener('error', function(event){
        console.log(event.target.statusText);
    });
    xhr.open('POST', '/db', true);
    xhr.send('data=' + data);
}
但当我使用
IE11
时,服务器每两次请求只接收一次数据:

1: 2:
我注意到,当我使用
Fiddler
进行调试时,服务器每次都接收数据。难道没有人能向我解释这个行为,以及如何修复它吗?

您是否尝试使用jQuery ajax功能?这样做的好处是它可以完美地跨浏览器工作,并且只需要一种语法。我知道,大多数人不喜欢使用额外的框架,但是这个框架简化了很多编码

e、 g:


同样的问题?而
jquery
POST http://localhost:99/db HTTP/1.1
Accept: */*
Referer: http://localhost:99/
Accept-Language: ru
Content-Type: text/plain;charset=UTF-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like 
Gecko
Host: localhost:99
Content-Length: 13
Connection: Keep-Alive
Cache-Control: no-cache

data=01234567
POST http://localhost:99/db HTTP/1.1
Accept: */*
Referer: http://localhost:99/
Accept-Language: ru
Content-Type: text/plain;charset=UTF-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like 
Gecko
Host: localhost:99
Content-Length: 13
Connection: Keep-Alive
Cache-Control: no-cache
    $.ajax({
      url:'https://my.server.com/myscript.php,
      type:'post',
      data: {
         var1: "x",
         var2: "y",
      },
      success: function(data) {
         // here goes the data, returned from your php script e.g.
      }
    });