随笔-124  评论-49  文章-56  trackbacks-0

var xmlrequestXml;
function createXmlHttpreqest(){
  if(window.ActiveXObject)
  {
        return new ActiveXObject("Microsoft.XMLHTTP");
  }else if(window.XMLHttpRequest)
  {
 return new XMLHttpRequest();
  }
}
var rul="?operate=doaa&uname="+uname;
1 创建xmlHttpRequest组件
xmlrequestXml=createXmlHttpreqest();
2 回调函数
xmlHttpRequest.onreadystatechange=haolejiaowo;、
3 注册
xmlHttpRequest.open("GET",url,true);
4 发送
xmlHttpRequest.send(null);

function haolejiaowo()
{
  if(xmlHttpRequest.readyState==4 && xmlHttpRequest.status=200)
  {
    var b=xmlHttpRequest.responseText;
    if(b=="true")
    {}
    else
    {}
  }
}

---------------------------------------------------------------------
1 jar http://getachead.org/dwr
2 创建配置文件:/WEB-INF/dwr.xml
  <dwr>
 <allow>
  <create creator="new[struts/spring]" javascript="JUserChecker">
  <param name="class" value="com.bj.biz.Manager"/>
 <!--
  <include method="check"/>
  <include method="check2"/>
 -->
 </allow>
  </dwr>
3 在web.xml中配置
  <servlet>
   <servlet-name>dwr</servlet-name>
   <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
   <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
   </init-param>
 <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dwr</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
  </servlet-mapping>
4 java类
 
5 测试 http://127.0.0.1:8080/dwrpro/dwr/
6 页面代码
<script src="dwr/interface/JUserChecker.js"/>

function checkUserExists(oCtl){
 var uname=oCtl.vlaue;
 JUserChecker.ckeck(uname,haoLeJiaoWo);
}
fucntion haoLeJiaoWo(data){
 alert(data); 
}

返回对象

posted on 2009-11-03 10:36 junly 阅读(202) 评论(0)  编辑  收藏 所属分类: ajax/jquery/js

只有注册用户登录后才能发表评论。


网站导航: