`
aaron_ch
  • 浏览: 179577 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

The Hot ajax

阅读更多

Famous of web2.0, the script language pushed the web forward based on ajax technology.
Currently,many ajax frameworks can be  used, such as dojo,sajax,dwr.....
But I insist on coding that by myself.


var request;
function createRequest(){
 try{
  request = new XMLHttpRequest();
 } catch (e){
  try{
   request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try{
    request = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e){
    alert("Your browser broke!");
    return false;
   }
  }
 }
 return request;
}

function ajaxRNTMP(phpurl,stuffid,idget1,idget2,idget3,idget4,idget5,idget6,idget7){
 
  model=getChangeValue(idget1);
  table=getChangeValue(idget2);
  datestart = document.getElementById(idget3).value;
  dateend = document.getElementById(idget4).value;
  ratio=getChangeValue(idget5);
  loc=getChangeValue(idget6);
  param=getChangeValue(idget7);
   //TODO : Validate form
  if(param==null || param==''){
     alert('Sorry,Please select paramerter!');
     return;
  }
  
  removePlot(stuffid,'ld');
  addElement();
  createRequest();
  querystring = "?model="+model+"&table="+table+"&datestart="+datestart+"&dateend="+dateend+"&ratio="+ratio+"&location="+loc+"&param="+param;
   
  request.open("GET", phpurl+querystring, true);
 request.onreadystatechange =function(){
  if(request.readyState == 4){
   if (request.status == 200){
   removeElement();
   ajaxDisplay = document.getElementById(stuffid);
   loading=document.createElement('img');
   loading.setAttribute('src',phpurl+querystring);
   loading.setAttribute('id', 'ld');
   ajaxDisplay.appendChild(loading);
   }
  }
 };
 request.send(null);
}

分享到:
评论

相关推荐

    [Mastering.Node.js(2013.11) 精通Node.js

    Introducing AJAX 149 Responding to calls 151 Creating a stock ticker 152 Bidirectional communication with Socket.IO 156 Using the WebSocket API 157 Socket.IO 159 Drawing collaboratively 161 Listening...

    The-Hungry-Guy:科大COMP4451项目

    2. **准备构建目录并启动开发服务器**:`yarn watch`是一个命令,它指示`yarn`在文件发生改变时自动重新构建项目,这通常与开发模式下的热加载(hot module replacement)相结合,使得开发者能够快速看到代码更改的...

    DNS-Analysis:非法域名挖掘与画像系统

    该项目包含大量的echarts和ajax使用,有一定的参考价值。 部署 # install dependencies npm install # serve with hot reload at localhost:8080 npm run dev # build for production with minification npm run ...

    jQuery完全实例.rar

    Additionally, the function, when executed, is passed a single argument representing the position of the element in the matched set (integer, zero-index). Returning 'false' from within the each ...

    vue-HuaweiAppStore:用webpack+vue+vuex+axios+ES6仿照开发的一个华为移动端的应用市场~

    install dependenciesnpm install# serve with hot reload at localhost:8080npm run dev# build for production with minificationnpm run build# build for production and view the bundle analyzer reportnpm ...

Global site tag (gtag.js) - Google Analytics