2

에서 궁금, 32 비트 시스템에서 작동하지 않습니다. 새로운 XMLHttpRequest 객체를 만들려고 할 때 형식 오류를 반환 자바 스크립트 IE8 표준 문서 모드에서 IE10을 사용하여 32 비트 시스템에서XMLHttpRequest의 누군가가 전에이 기괴한 IE/자바 스크립트 오류에 충돌 한 경우 IE10 IE8 표준 문서 모드

. 이는 우리 페이지 중 하나가 X-UA 호환 IE = 8 메타 태그 (페이지 요구 사항)를 통해 IE8 표준을 강제 적용하기 때문에 문제가됩니다.

새로운 window.XMLHttpRequest();
형식 오류 : 개체가 (IE8 표준에서 IE10)이 작업

에게 64 비트 컴퓨터에서 코드의이 동일한 라인을 지원 잘 작동하지 않습니다.

32 비트 IE10 IE8 표준
32-bit IE10 IE8 standards

64 비트 IE10 IE8 표준 내가 AngularJS와 버전 1.2.9을 사용하여 유사한 문제로 실행
64-bit IE10 IE8 standards

답변

1

. 밝혀지면, angle은 window.XMLHttpRequest()의 가용성을 감지하는 가장 좋은 일을하지 않습니다. jQuery는 좀 더 철저히 접근합니다.

:

AngularJS와 1.2.9

function createXhr(method) { 
    // IE8 doesn't support PATCH method, but the ActiveX object does 
    /* global ActiveXObject */ 
    return (msie <= 8 && lowercase(method) === 'patch') 
     ? new ActiveXObject('Microsoft.XMLHTTP') 
     : new window.XMLHttpRequest(); 
} 

jQuery를 나를 위해 1.10.2

// Functions to create xhrs 
function createStandardXHR() { 
    try { 
     return new window.XMLHttpRequest(); 
    } catch(e) {} 
} 

function createActiveXHR() { 
    try { 
     return new window.ActiveXObject("Microsoft.XMLHTTP"); 
    } catch(e) {} 
} 

// Create the request object 
// (This is still attached to ajaxSettings for backward compatibility) 
jQuery.ajaxSettings.xhr = window.ActiveXObject ? 
    /* Microsoft failed to properly 
    * implement the XMLHttpRequest in IE7 (can't request local files), 
    * so we use the ActiveXObject when it is available 
    * Additionally XMLHttpRequest can be disabled in IE7/IE8 so 
    * we need a fallback. 
    */ 
    function() { 
     return !this.isLocal && createStandardXHR() || createActiveXHR(); 
    } : 
    // For all other browsers, use the standard XMLHttpRequest object 
    createStandardXHR; 

// Determine support properties 
xhrSupported = jQuery.ajaxSettings.xhr(); 

는 수정 각도의 createXhr 방법에 IE8 문서 모드로 확인하는 추가 조건을 추가했다

function createXhr(method) { 
    // IE8 doesn't support PATCH method, but the ActiveX object does 
    /* global ActiveXObject */ 
    return ((msie <= 8 && lowercase(method) === 'patch') || 
     (msie >= 8 && document.documentMode == 8)) 
     ? new ActiveXObject('Microsoft.XMLHTTP') 
     : new window.XMLHttpRequest(); 
} 

대안이 있는지 확인하기 위해 보이는 jQuery의 방식을 구현하는 것입니다 ActiveXObject 사용할 수 있습니다. 그런 다음 표준 XMLHttpRequest를 만들려고 시도하는 경우 실패하면 다시 ActiveX 대안으로 넘어갑니다.