六月丁香五月婷婷,丁香五月婷婷网,欧美激情网站,日本护士xxxx,禁止18岁天天操夜夜操,18岁禁止1000免费,国产福利无码一区色费

學(xué)習(xí)啦>知識(shí)大全>方法百科>產(chǎn)品使用方法>

ajax調(diào)用java方法(2)

時(shí)間: 陳哲凡673 分享

  ajax調(diào)用java方法(三)

  var http_request=false;

  function sendRequest(method,url,content,processResponse)

  {

  http_request=false;

  if(window.XMLHttpRequest) //mozilla

  {

  http_request=new XMLHttpRequest();

  }else if(window.ActiveXObject) //IE

  {

  try

  {

  http_request=new ActiveXObject("Msxml2.XMLHTTP");

  }catch(e)

  {

  http_request=new ActiveXObject("Microsoft.XMLHTTP");

  }

  }

  if(!http_request)

  {

  alert("異步通信對(duì)象創(chuàng)建失敗!");

  return;

  }

  if(method.toLowerCase()=="get")

  {

  http_request.open(method,url,true);

  http_request.onreadystatechange=processResponse;

  http_request.send(content);

  return;

  }

  if(method.toLowerCase()=="post")

  {

  http_request.open(method,url,true);

  http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

  http_request.onreadystatechange=processResponse;

  http_request.send(content);

  return;

  }

  }

  function getResult()

  {

  if(window.http_request.readyState==4)

  {

  if(window.http_request.status==200)

  {

  //這是返回的結(jié)果

  var rText=window.http_request.responseText;

  //處理結(jié)果

  if(rText=="true")

  {

  alert("用戶名稱已經(jīng)存在");

  }else{

  alert("用戶名稱可以使用");

  }

  }

  }

  }

  //調(diào)用

  sendRequest("POST","user.do","userName="+name,getResult);

374678