Ajax示例
客户端代码:
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function sl(url){
//可加一些验证信息
document.getElementById('slform').style.display='';//打开受理form
//alert("url="+url);
createXMLHttpRequest();//为 xmlHttp 赋值
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = slcallback;
xmlHttp.send(null);
}
function slcallback(){
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var applyPerson = xmlHttp.responseXML.getElementsByTagName('applyPerson')[0].firstChild.data;
var applyIdCard = xmlHttp.responseXML.getElementsByTagName('applyIdCard')[0].firstChild.data;
document.getElementById('slPerson').value=applyPerson;
document.getElementById('slId').value=applyIdCard;
}
}else{
}
}
在action里,返回到一个jsp页面,在jsp页面里把内容设为xml格式
如下:
<%@ page contentType="text/xml; charset=GBK"%>
<%
String applyPerson = (String)request.getAttribute("applyPerson");
String applyIdCard = (String)request.getAttribute("applyIdCard");
%>
<?xml version="1.0" encoding="GBK"?>
<response>
<applyPerson><%=applyPerson%></applyPerson>
<applyIdCard><%=applyIdCard%></applyIdCard>
</response>
相关文档:
index.asp文件 保存utf-8
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
<form id="form1" name="form1" method="post">
<input name="ip" type="text" id="ip" style="width:170px" />
</form>
<mce:script type="text/javascript" src="ajaxrequest-m ......
Ajax 给 XMLHttpReq.onreadystatechange传递参数
通过:
xmlhttp.onreadystatechange= function(){xx(123)};
or
xmlhttp.onreadystatechange= new Function("xx(123)");
就可以了。
m=document.getElementsByName("text8");
v=m[i];
XMLHttpReq.onreadystatechange=function(){proce(v)};
---------------------- ......
Dojo1.3.x
的
Ajax
示例
整理人:黄诚
QQ
群:
65643887
这篇文章主要是帮助对
Dojo
感兴趣的朋友们快
速实现网站上的例子。
http://sitepen.com/labs/guides/?guide=DojoQuickStart#Ajax
它教程分了
3
部分,其中的例子不容易
上手。我这里提供一个打包文件
AjaxWithDojo.war
下面我将详细说明操作步� ......
Web开发者不会注意到由 “AJAX(Asynchronous JavaScript And XML)”所带来的激情。不费力气就能创建像Google Suggest那样的智能网站或者像Gmail那样基于Web的应用程序,这在很大程度上要归功于这种技术。然而,伴随着AJAX应用程序的发展,我们发现了它的一些不足之处,我们发现它的安全漏洞也在逐渐变大,就像慢� ......