ajax ÖÐÎÄÂÒÂë - Java / Web ¿ª·¢
ÔÚservletÖУ¬ÓÐÖÐÎÄ´«µÝµ½Ò³ÃæÖеÄjsÀïÃ棬ÔÚjsÏÔʾÖÐÎÄʱ£¬³öÏÖÂÒÂë¡£
serletÀïÃ沿·Ö´úÂ룺
Java code:
StringBuffer sb=new StringBuffer("<nprovince>");
for(City city:clist){
sb.append("<scity>").append(city.getCityId()).append("</scity>");
sb.append("<scity>").append(new String(city.getName().getBytes("iso8859-1"),"utf-8")).append("</scity>");
//´«µÝÖÐÎÄÃû³Æ¡£
}
sb.append("</nprovince>");
jspÖеÄjs²¿·Ö´úÂ룺
JScript code:
if(req.status == 200){
var city=req.responseXML.getElementsByTagName("scity");
var str=new Array();
var strname=new Array();
for(var i=0;i<city.length;i=i+2){
str[i]=city[i].firstChild.data;
strname[i]=city[i+1].firstChild.data;
alert(unescape(strname[i]));//ÖÐÎÄÂÒÂë
}
buildSelect(str,strname,document.getElementById("scity"));
}
ÔÚ·þÎñÆ÷¶Ë·µ»Ø°üº¬ÖÐÎĵĴ¦Àí½á¹ûʱ£¬Ö¸¶¨charsetΪUTF-8£¬¿É±£Ö¤¿Í»§¶ËAjax¶ÁÈ¡responseXML»òresponseTextΪÖÐÎÄ£¬´ËÍ⻹ÐèҪעÒâ»ñÈ¡PrintWriterµÄ²½ÖèÒ»¶¨Òª±£Ö¤ÔÚ¶ÔresponseÉèÖÃÍê±ÏcontentTyp
Ïà¹ØÎÊ´ð£º
<script language="javascript">
var XMLHttpReq;
var cont=true;
//´´½¨XMLHttpRequest¶ÔÏó
function createXMLHttpRequest ......
ÎÒJSPµÄÒ³ÃæÊÇ£º
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
¸÷·´óÏÀ¸ø¸ö˼·£¬²»ÊÇÔÚÏßµÄÄÇÖÖ£¬¾ÍÊÇÒ»¸ö×öÆÕͨµÄÓ¦ÓóÌÐò¡£
´Ê¿âÔõôÉú³ÉÄØ£¿
²»»á¡£
ÒýÓÃ
´Ê¿âÔõôÉú³ÉÄØ£¿
ÕÒ±¾×Öµä
ÒýÓÃ
´Ê¿âÔõôÉú³ÉÄØ£¿
Êý¾Ý¿â ºÇºÇ
ÓÃmap ¼üÖµ¶ÔÓ¦
Èç¹ûÓÃÊý¾Ý¿ ......
ÓÃStruts2+Spring+Hibernate×öµÄÒ»¸öwebµÄERPСÏîÄ¿£¬×ܲ¿Ò»Ì¨·þÎñÆ÷£¨Êý¾Ý¿âÓëWeb·þÎñÆ÷ÔÚͬһ»ú×ÓÉÏ£©Êǵ¥¶À²¦ºÅÉÏÍøµÄ£¬Óë·Ö¹«Ë¾Ã»ÓÐÓþÖÓòÍøÏߣ¬Ó²¼þÌ«¹óÁË£¬ÆäËû¼¸¸öÊ¡Êзֹ«Ë¾¶¼À´·ÃÎÊÕâÒ»·þÎñÆ÷£¬¸Ð¾õºǫ́´ú ......