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);
}
返回对象