1

아약스를 사용하여 내 페이지로 데이터를 가져오고 .html()을 사용하여 div의 HTML 콘텐츠를 변경합니다. 인터넷 익스플로러를 제외하고 모두 파이어 폭스, 구글 크롬, 사파리, 오페라에서 잘 작동합니다..html()이 인터넷 익스플로러에서 작동하지 않습니다.

IE 7, 8, 9가 .html() 기능에 응답하지 않으면 해당 div의 내용은 변경되지 않습니다.

var userurl = $('#userthumb a').attr('href'); 
$(document).ready(function(){ 
    $('#userthumb').after("<div id='to-change'>Loading...</div>"); 
     $.ajax({ 
      type: "GET", 
      url: "parse.php", 
      data: "url=" + userurl, 
      dataType: 'json', 
      cache: false, 
      success: function(data) 
      { 
       var respond = data['respond'];  
        $('#to-change').html(respond + 'profile'); 
      } //end of success 
      }); //end of ajax 
}); 

어떤 문제가 있거나 IE의 문제를 해결하는 방법이있다 :

여기 내 코드입니까?

+0

반환되는 HTML은 어떤 모양입니까? 태그가 누락되면 IE에서 혼란을 겪을 수 있습니다. –

+0

http://stackoverflow.com/questions/412734/jquery-html-attribute-not-working-in-ie – ComfortablyNumb

+0

으로 복제 됨 JSON { "respond": "username"} – sm21guy

답변

0

을보십시오이 그것을 해결할 수 있습니다

success: function(data) { 
    eval('var jSON = '+data); 
    $('#to-change').html(jSON['respond'] + 'profile'); 
} //end of success 

편집 : 내 VB 스크립트에서

{'respond':'it worked as expected','.....':'....'} 

을 : 당신의 반환 데이터가 예를 들어, 형식에 있는지 확인 돌아왔다 :

.. 그런 다음
response.write "{'Success':'MoveOn','....':'....'}" or 
response.write "{'Success':'Error:........','....':'....'}" 

,

eval('var jSON='+data); 
if (jSON['Success'] == 'MoveOn') ....... 
+2

Eval? No thank you ... – JCOC611

+0

요소 목록 뒤에 "missing"오류가 반환됩니다. "var jSON = [Object object]; – sm21guy

+0

그래서 두 개의 객체가 필요합니다 – sm21guy

0

$('#to-change').html($.parseJSON(data).respond + 'profile'); 
+0

$. parseJSON (data) is null? – sm21guy

0

이 시도 : $를 ('#으로 변화') 빈() 추가 ('프로필'+ 응답);

관련 문제