IT::Scripting::JavaScript::SJAX(AJAX)のサンプル::JavaScript側

function env_log_ajax()
{
   var url = 'http://[Ajax testserver]/cgi-bin/[http://d.hatena.ne.jp/sapphire_code/20070416:title=env_log.pl]';
   var browse_debug = ''; // 1 ... on / null ... off
   var rtn='';
   
   //if(browse_debug ){window.open(url,'','');}
   //alert(ajax_logw( url , browse_debug));
   rtn = ajax_logw( url , browse_debug);
}



function ajax_logw( url , debug)
{
  //alert('JP : '+JP);
  var xmlhttp = null ;
  
  var msXml = [ 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' ]
  if ( typeof ActiveXObject != "undefined" ) {
      for ( var ci=0; ci < msXml.length; ci++ ) {
          xmlhttp = new ActiveXObject( msXml[ci] ) ;
          if ( xmlhttp ) break ;
      }
  }
  else if ( typeof XMLHttpRequest != "undefined" ) {
      xmlhttp = new XMLHttpRequest() ;
  }
  if (!xmlhttp) return;
    dofile=url+'?';
  //alert('dofile : '+dofile);
  // 第3引数
  // true  ... 非同期 /AJAX
  // false ... 同期   /SJAX
  if(debug){window.open(dofile+'&openwindowflag=1','','');}
  xmlhttp.open('GET', dofile, false );
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status == 200) {
      //window.strDATAFMT = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);

//  alert(xmlhttp.responseText);
  return xmlhttp.responseText;
}