AJAXÇëÇó
¿Í»§¶ËHTMLPage.htmÒ³Ãæ
HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="XmlHttp.js" type="text/javascript"></script>
<head>
<title></title>
<script type="text/javascript">
function a() {
var url = "Handler2.ashx";
Request.sendGET(url, Success, Failture);
}
function Success(req) {
ÕâÊÇ´Ó·þÎñÆ÷·µ»ØµÄ"<script language="javascript" src="test.js"></script>"
Ôõôֱ½ÓÈÃÕâ¶ÎjsÖ±½ÓÔËÐÐ
"req.responseText"ÕâÒ»¶ÎÒ²¾ÍÊÇÏÂÃæµÄÕâ¶ÎÓ¦¸ÃÔõô´¦Àí
req.responseText
}
function Failture() {
alert();
}
</script>
</head>
<body onload="a();">
<div id="1">1</div>
<div>2</div>
<div>3</div>
</body>
</html>
·þÎñÆ÷¶ËÒ³ÃæHandler2.ashx
C# code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.C
Ïà¹ØÎÊ´ð£º
ÎÒÏÖÔÚÓÃstruts2¿ò¼Ü,ÐèҪʹÓÃajaxʵÏÖ¾Ö²¿Ë¢Ð£¬µ«ÊÇ´ÓÈÝÆ÷Àï·µ»ØµÄÖµ²»ÖªµÀÔõô´Óstruts.xmlÅäÖÃÎļþÀïÓ³Éäµ½jspÒ³ÃæÀÒÔǰservletÀïдout.orint("xxxxx")¾Í¿ÉÒԵõ½~£¬µ«ÊÇÏÖÔÚÓÃstruts¾Í²»ÖªµÀÔõôР......
ÎÒJSPµÄÒ³ÃæÊÇ£º
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
$(document).ready(function() {
function listparam(param) {
param.OperationFlag = 1;
return param;
}
var param = {
ClassNam ......
ÎÒÏÖÔÚÓÐÒ»¸ö¼òµ¥ÐÅÏ¢ÁÐ±í£¬ÏÖÔÚÎÒÏëµã»÷²é¿´Ê±£¬»áµ¯³öÒ»¸öÀàËÆÓë²é¿´´óͼÄÇÑùµÄЧ¹û£¬°ÑÏêϸÐÅÏ¢ÏÔʾ³öÀ´£¬
×îºÃÊÇÔÚµ¯³öºóÔÙÇëÇó»ñÈ¡ÏêϸÐÅÏ¢£¬Õâ¸öЧ¹û¸ÃÔõô×öÄØ£¿½ô¼±ÇóÖú¸ßÊÖ°¡
Jquery!
ajax£¬µ¯³ödi ......
ÔÚservletÖУ¬ÓÐÖÐÎÄ´«µÝµ½Ò³ÃæÖеÄjsÀïÃæ£¬ÔÚjsÏÔʾÖÐÎÄʱ£¬³öÏÖÂÒÂë¡£
serletÀïÃæ²¿·Ö´úÂ룺
Java code:
StringBuffer sb=new StringBuffer("<nprovince>");
for(City city:clist){
......