2012-12-14 3 views
0

카테고리 선택 목록에서 선택한 항목을 기준으로 하위 카테고리의 선택 목록에 값을 가져 오려고합니다. 그것은 IE에서 작동하지 않는 것 같습니다. 누구든지 문제를 제안 할 수 있습니까?javascript/ajax 드롭 다운이 IE에서 작동하지 않습니다.

내 코드가 Firefox, Chrome, Opera 및 Safari에서 올바르게 작동하지만 IE7,8,9에서 작동하지 않습니다!

JS 코드 : FF에서

<!-- Begin CHack For Ostan --> 
function getOstan(str) 
{ 
if (str.length==0) 
    { 
    document.getElementById("SH_O").innerHTML=""; 
    return; 
    } 
if (window.XMLHttpRequest) 
    {// code for IE7+, Firefox, Chrome, Opera, Safari 
    xmlhttp=new XMLHttpRequest(); 
    } 
else 
    {// code for IE6, IE5 
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
xmlhttp.onreadystatechange=function() 
    { 
    if (xmlhttp.readyState==4 && xmlhttp.status==200) 
    { 
    document.getElementById("SH_O").innerHTML=xmlhttp.responseText; 
    } 
    } 
xmlhttp.open("GET","listing.php?q="+str,true); 
xmlhttp.send(); 
} 
<!-- END --> 
<!-- Begin CHack For City --> 
function getSH_O(str) 
{ 
if (str.length==0) 
    { 
    document.getElementById("SH_C").innerHTML=""; 
    return; 
    } 
if (window.XMLHttpRequest) 
    {// code for IE7+, Firefox, Chrome, Opera, Safari 
    xmlhttp=new XMLHttpRequest(); 
    } 
else 
    {// code for IE6, IE5 
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
xmlhttp.onreadystatechange=function() 
    { 
    if (xmlhttp.readyState==4 && xmlhttp.status==200) 
    { 
    document.getElementById("SH_C").innerHTML=xmlhttp.responseText; 
    } 
    } 
xmlhttp.open("GET","listing.php?z="+str,true); 
xmlhttp.send(); 
} 
<!-- END --> 

:

enter image description here

IE의 경우 :

enter image description here

+1

뭔가 하더군요을 사용하는 것이 좋습니다 jQuery와 3 줄짜리 브라우저가있다. 코드를 읽지도 않는다. – adeneo

+0

사진을 추가, 질문을 다시 확인하시기 바랍니다 – Mohammad

답변

0

function getXHRequest() { 
    try { return new XMLHttpRequest(); } catch(e) {} 
    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} 
    alert("XMLHttpRequest not supported"); 
    return null; 
} 

var xmlhttp = getXHRequest(); 
xmlhttp.open("GET","listing.php?z="+str,true); 
xmlhttp.send(); 

니어 당신이 그 물건의 십자가를 할 수있는 (등 테스트, 크로스 브라우저,) jQuery를 같이, 당신을 위해 일을 할 것입니다 도서관

$.ajax({url: "listing.php?z="+str}).done(function(data){ 
    $("SH_C").html(data); 
}); 
+0

이 코드를 작동하지 않습니다 :( – Mohammad

+0

그것은 아작스 문제가되지 않을 수 있습니다 IE는 당신이'innerHTML'을 사용하여 선택의 옵션을 추가 할 수 없습니다. – krampstudio

관련 문제