본문 바로가기

jQuery

jQuery In Action chapter 8-1

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>예제 8.3</title>
 <script type="text/javascript">
 window.onload = function (){
  var xhr;

  if (window.XMLHttpRequest) {
   xhr = new XMLHttpRequest();
  } else if (window.ActiveXObject) { 
   xhr = new ActiveXObject("Msxml2.XMLHTTP");
  } else {
   throw new Error("Ajax를 지원하지 않는 브라우저입니다.");
  }

  xhr.onreadystatechange = function (){
   if (xhr.readyState == 4) {
    if (xhr.status >= 200 && xhr.status < 300) {
     document.getElementById('someContainer').innerHTML = xhr.responseText;
    }
   }
  };
  xhr.open('GET', 'someResource');
  xhr.send('');
 };
 </script>
</head>
<body>
 <div id="someContainer"></div>
</body>
</html>

'jQuery' 카테고리의 다른 글

datejs  (0) 2009.12.21
jQuery In Action chapter 8-2  (0) 2009.12.20
jQuery In Action chapter 4-5  (0) 2009.12.20
jQuery In Action chapter 4-4  (0) 2009.12.20
jQuery In Action chapter 4-3  (0) 2009.12.20