易截截图软件、单文件、免安装、纯绿色、仅160KB

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>


相关文档:

asp ajax 查看IP的所在地

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 ......

关于JSP页面用UTF 8编码AJAX失效的问题

在一个项目中分级选择行政区划时用到AJAX进行无刷新级联,我在页面中编码用的是UTF-8,总是报脚本错误,
我把页面编码换成GBK又是正常的,后来在网上搜索了一下,在引入JS时加入编码就可以了,如下:
<script language="Javascript" src="js/jquery.js" charset="gb2312"></script> ......

Ajax 给 XMLHttpReq.onreadystatechange传递参数

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)};
---------------------- ......

ajax连动下拉菜单

-------------------------jsp中的js代码--------------------
<script type="text/javascript">
  function ajaxFunction(sort){
   var xmlHttp;
   try{
      // Firefox, Opera 8.0+, Safari
       xmlHttp=new X ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号