XMLHttpRequest won't work in IE 7/8 but works in other browsers

前端 未结 2 847
时光取名叫无心
时光取名叫无心 2021-01-12 16:38

I\'ve developed a web application that works well on chrome and firefox. However when it came to testing time and it doesn\'t work properly in IE. It just doesn\'t seem to a

2条回答
  •  走了就别回头了
    2021-01-12 17:15

    As mentioned here, Internet Explorer supports the onload event of the XMLHttpRequest object only since version 9.

    So, for IE 8 and below, you can do it in the old fashioned way:

    xhr.onreadystatechange = function()
    {
        //ready?
        if (xhr.readyState != 4)
            return false;
    
        //get status:
        var status = xhr.status;
    
        //maybe not successful?
        if (status != 200) {
            alert("AJAX: server status " + status);
            return false;
        }
    
        //Got result. All is good.
        loading.innerHTML = 'Print Report' + 
            '

    HomePage
    ' + 'Refresh
    ' + 'Logout
    '; target.innerHTML = xhr.responseText; return true; }

提交回复
热议问题