100·ÖÇóajax·µ»ØÖµÎÊÌ⣡
100·ÖÇóajax·µ»ØÖµÎÊÌ⣡2¸öajaxÇëÇóͬ1Ò³Ãæ£¬Ôõô²ÅÄÜÈ÷µ»ØÖµÄÜ¿ØÖÆÎÒÏëÒª¸üеÄlayerÄØ£¿
HTML code:
function ajax1()
{
var xmlHttp;
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById("Layer1").innerHTML=xmlHttp.responseText;
}
}
xmlHttp.open("GET","a.asp",true);
xmlHttp.send(null);
}
function ajax2()
{
var xmlHttp;
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById("Layer2").innerHTML=xmlHttp.responseText;
}
}
xmlHttp.open("GET","a.asp",true);
xmlHttp.send(null);
}
a.asp
HTML code:
<script type="text/javascript">
window.onload =function() {
window.parent.ajax1();
window.parent.ajax2();
}
</script>
<%response.write"ÕâÀïÔõôд°¡£¿£¿£¿¼ÙÈçÎÒÖ»¸üÐÂLayer1µÄ»°¡£¡£¡£"%>
xmlHttp.send(null);
ÕâÀï¼Ó¸ö²
Ïà¹ØÎÊ´ð£º
֮ǰÓöµ½Ò»¸öÎÊÌâ¡£
ÓÚÊÇ×öÁËÒÔÏÂʵÑ飺
Ò³Ãæ¼ÓÔØºó£¬Ìá½»Ò»¸öAjaxÇëÇó(ÔݳÆÎªajax1)£¬ÇëÇóµÄÏß³ÌÔÚ·þÎñÆ÷Éϱ»Ë¯Ãß10ÃëÖÓ¡£
µã»÷Ò³ÃæÉÏÒ»¸öbutton£¬´¥·¢ÁíÒ»¸öAjaxÇëÇó(ajax2)¡£
µ±Ã»ÓÐʹÓÃsession£¬ÔÚ·þÎñÆ÷δ´ ......
ÎÒÏÖÔÚÓÃstruts2¿ò¼Ü,ÐèҪʹÓÃajaxʵÏÖ¾Ö²¿Ë¢Ð£¬µ«ÊÇ´ÓÈÝÆ÷Àï·µ»ØµÄÖµ²»ÖªµÀÔõô´Óstruts.xmlÅäÖÃÎļþÀïÓ³Éäµ½jspÒ³ÃæÀÒÔǰservletÀïдout.orint("xxxxx")¾Í¿ÉÒԵõ½~£¬µ«ÊÇÏÖÔÚÓÃstruts¾Í²»ÖªµÀÔõôР......
ÎÒÔÚÒ»¸öhtmlÖÐдÈçÏ´úÂ룺
JScript code:
<html>
<head>
<script type="text/javascript" charset="utf-8"
src="script/jquery-1.3.2.min ......
ÊÇÐÂÊÖ
´úÂëÈçÏ£º
test.jsp:
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" ......