2011-02-27 5 views
2

jquery의 .load() 함수가 작동하지 않습니다. 뭔가 간단해야한다. 기본적으로 more.html의 조각을 index.html에로드하려고한다.jquery .load()가 작동하지 않습니다.

index.html을

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <script type="text/javascript" src="js/jquery-1.5.js" /> 
    <title>Test</title> 

    <script type="text/javascript"> 
     $(document).ready(function() { 
      alert("jquery script executing..."); 
      $('#foo').load('more.html #bar', loadComplete); 
     }); 

     function loadComplete (response, status, xhr) { 
      alert("load complete."); 
     } 
    </script> 
</head> 
<body> 
    <div id="foo"> 
     foo foo foo 
    </div> 
</body> 
</html> 

more.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>More</title> 
</head> 
<body> 
    <div id="bar"> 
     bar bar bar 
    </div> 
</body> 

내가 모두 경고를 참조 - 스크립트가 실행되고 있으며, 콜백이되고 있습니다 호출 (즉,로드가 완료 중입니다). 그러나 내용은 변경되지 않습니다. 나는 사파리, 크롬, 파이어 폭스 (모두 OSX)를 시험해 보았다. 내가 잃어버린 명백한 뭔가가있을거야 ...?

답변

4

로드 기능은 jquery 1.5 릴리스에서 작동하지 않습니다. 버그 티켓은 http://bugs.jquery.com/ticket/8125에서 찾으실 수 있습니다. 이 문제는 버전 1.5.1에서 수정되었습니다. load()를 포함하여 최신 수정 사항이 포함 된 최신 jquery 릴리즈를 찾을 수 있습니다. http://code.jquery.com/jquery-git.js

+0

aiaiaiai. 그러면 그걸 설명 할 수 있습니다. jquery 공개 토론에 동일한 질문을 배치하는 시도하고 아무것도 얻지 않았다. 나는 stackoverflow 날 사랑 줄 알았어. 감사! – ericsoco

+0

1.5.1이 배포되었습니다. –

+0

1.5.1 축소 된 형식 Google CDN : https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js – dermatthias

관련 문제