DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> AJAX入門 >> AJAX基礎知識 >> javascript Ajax獲取遠程url的返回判斷
javascript Ajax獲取遠程url的返回判斷
編輯:AJAX基礎知識     
復制代碼 代碼如下:
  <SCRIPT LANGUAGE="JavaScript">
  <!--
  function ajaxByJyking(){
  var xmlhttp_request = "";
  try{
  if( window.ActiveXObject ){
  for( var i = 5; i; i-- ){
  try{
  if( i == 2 ){
  xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" ); }
  else{
  xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
  xmlhttp_request.setRequestHeader("Content-Type","text/xml");
  xmlhttp_request.setRequestHeader("Charset","gb2312"); }
  break;}
  catch(e){
  xmlhttp_request = false; } } }
  else if( window.XMLHttpRequest )
  { xmlhttp_request = new XMLHttpRequest();
  if (xmlhttp_request.overrideMimeType)
  { xmlhttp_request.override.MimeType('text/xml'); } } }
  catch(e){ xmlhttp_request = false; }
  xmlhttp_request.open('GET', 'http://www.jb51.net', true);
  xmlhttp_request.send(null);
  xmlhttp_request.onreadystatechange = function(){
  if (xmlhttp_request.readyState == 4) {
  // 收到完整的服務器響應
  document.write("yes")
  } else{
  alert(1)
  }
  }
  }
  ajaxByJyking();
  //-->
  </SCRIPT>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved