2012-04-26 2 views
0

동료가 API에 양식을 게시하고 iframe에서 XML 응답을받은 다음 XML로 어린이를 파싱하는 버그를 해결하려고합니다. 페이지는 IE9, 크롬, 파이어 폭스에서 작동하지만 IE 8Javascript getElementsByTagName이 IE8에서 제대로 당겨지지 않음

형태로되어

<form action="../../includes/functions/ADapi.php" method="POST" target="response" id="addForm" > 
<fields galore></fields galore> 
</form 

<iframe name="response" id="response" style="display:none;" ></iframe> 

응답 :

<?xml version="1.0" encoding="utf-8" ?> 
- <xmlresponse> 
    <DateTime>2012-04-26 15:36:47</DateTime> 
    <confirmationcode>success</confirmationcode> 
    </xmlresponse> 

자바 스크립트 :

function getResponse() 
    { 
     var myIFrame = document.getElementById("response"); 
     var content = myIFrame.contentWindow.document.getElementsByTagName('confirmationcode'); 
     var insertID = myIFrame.contentWindow.document.getElementsByTagName('id'); 
     //var sql = myIFrame.contentWindow.document.getElementsByTagName('SQL'); 
     var response = $(content).text(); 
     var responseID = $(insertID).text(); 
     //alert($(sql).text()); 

     if(response == "Success" || response == 'success') 
     { 
      if(mode == 'edit') 
      { 
       post_to_url("/edit-contact", {type: 'edit', cust: id, mod: 'update',field : '<?php if(isset($_POST['field'])){ echo $_POST['field']; }?>',operator : '<?php if(isset($_POST['operator'])){ echo $_POST['operator']; }?>',criteria : '<?php if(isset($_POST['criteria'])){ echo $_POST['criteria']; }?>'}); 
      } 
      else 
      { 
       post_to_url("/edit-contact", {type: 'edit', cust: responseID, mod: 'insert',field : '<?php if(isset($_POST['field'])){ echo $_POST['field']; }?>',operator : '<?php if(isset($_POST['operator'])){ echo $_POST['operator']; }?>',criteria : '<?php if(isset($_POST['criteria'])){ echo $_POST['criteria']; }?>'}); 
      } 

     } 
     else 
     { 
      alert("Error!"); 
     } 


    } 

실행될 때마다 'Error!'라는 경고가 팝업됩니다.

도움을 주시면 감사하겠습니다.

+0

응답을 포함 할 수있는 다른 방법이 있습니까? 'else '에'console.log (response);'를 넣었습니까? 덧붙여서,'alert()'로 디버깅을할까요? 하지마. 그것은 엄청나게 침입 적이며, 당신은 일을하고 흐름을 따르는 것보다 일을 일축시키는 터무니없는 시간을 보냅니다. IE9는 꽤 최신 버전입니다. IE 7은 무엇을합니까? 9 작품이 있고 7 작품이 아니라면, IE9 이전 버전에 의존하고있는 것을 제안합니다. –

+0

귀하의 질문에 답변하지는 않지만 왜 그 응답을 iframe에 넣으시겠습니까? XmlHttpRequest를 사용하여 Ajax 요청을 사용하고 응답을 구문 분석하지 않는 이유는 무엇입니까? – Cheeso

+0

나는 그것을 만들지 않았다. 나는 단지 그것을 고치려고 노력하고있다. 우선 순위가 낮은 버그이지만 내일 아침 10시에 AJAX를 사용하여 다시 빌드 할 시간이 없습니다. –

답변

0

AJAX를 사용하기 위해 페이지를 다시 작성했습니다. 그것은 필요 이상으로 오래 걸렸지 만, 나는 그것을 옮겼다. here으로 지적했듯이, 설정 한 방식대로 작동하지 않으므로 수행 할 수있는 다른 작업이 필요했습니다.

1

IE8은 HTML 문서 (window.document)에서 쿼리하는 경우 HTML에서 유효한 요소 만 인식합니다. XmlHttpRequest에 의해 반환되는 것과 같이 XML 문서를 쿼리하는 경우 올바르게 작동합니다.

관련 문제