在頁面中動態查詢數據庫信息

var http_request = false;
function createXMLHttpRequest() {

 if (window.XMLHttpRequest) { // Mozilla, Safari,...
  http_request = new XMLHttpRequest();
  if (http_request.overrideMimeType) {
   http_request.overrideMimeType('text/xml');
  }
 } else if (window.ActiveXObject) { // IE
  try {
   http_request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {}
  }
 }

 if (!http_request) {
  alert('Giving up :( Cannot create an XMLHTTP instance');
  return false;
 }

}

 

function makeRequest(action,url) {
 createXMLHttpRequest();

 if (http_request)
 {
  http_request.onreadystatechange = action;     //此處action爲獲得相應的信息後要執行的處理程序
  http_request.open("GET", url, true);
  http_request.send(null);
 }
 return true;

 

function funciton_name() {
 var adpinfo='';
 if (http_request.readyState == 4) {
  if (http_request.status == 200) {
   adpinfo=http_request.responseText;
  } else {
   adpinfo=' ';
  }
//此處對獲得的信息進行處理 

}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章