กันลืม
พอดีมีปัญหาจนต้องกลับมาใช้แบบ old school - -"

// Load when DOM ready

Window.onDomReady(function(){
  demo();
});

function loadXMLDoc(pmethod, purl, pasync, pcontent_type){
  var xmlhttp;
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      var data=xmlhttp.responseText;
    }
  }
  xmlhttp.open(pmethod, purl, pasync);
  xmlhttp.setRequestHeader("Content-type", pcontent_type);

  
  // If send with POST input data tot here
  // E.g. fname=Henry&lname=Ford
  xmlhttp.send();
}

function demo(){

  // Can change method to POST
  loadXMLDoc("GET", 'index.php', false, "text/html");
}

Comments