ÏÈ˵ͨ¹ýjavascript·¢ËÍʱµÄÂÒÂëÎÊÌ⣬Èç¹û·¢Ë͵ÄÊÇÖÐÎÄ£¬¾ÍÒªÓÃescapeÕâ¸öº¯Êý´¦Àí£¬±ÈÈ磺
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
var url="testurl.php?name="+"¸Õ¸Õ";
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
ÄÇô¾ÍÒª¸Ä³É
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
var url="testurl.php?name="+escape(¸Õ¸Õ);
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
ÏÂÃæ˵һϽÓÊÕʱµÄÂÒÂëÎÊÌ⣬ÓÃAJAXÀ´GET»ØÒ»¸öÒ³Ãæʱ£¬responsetextÀïÃæµÄÖÐÎĶà°ë»á³öÏÖÂÒÂ룬ÕâÊÇÒòΪXmlhttpÔÚ´¦Àí·µ»ØµÄresponseTextµÄʱºò£¬ÊÇ°ÑresposeBody°´UTF-8±àÂë½ø½âÂ뿼Ðγɵģ¬Èç¹û·þÎñÆ÷ËͳöµÄȷʵÊÇUTF-8µÄÊý¾ÝÁ÷µÄʱºòºº×Ö»áÕýÈ·ÏÔʾ£¬¶øËͳöÁËGBK±àÂëÁ÷µÄʱºò¾ÍÂÒÁË¡£½â¾öµÄ°ì·¨¾ÍÊÇÔÚËͳöµÄÁ÷ÀïÃæ¼ÓÒ»¸öHEADER£¬Ö¸Ã÷ËͳöµÄÊÇʲô±àÂëÁ÷£¬ÕâÑùXmlHTTP¾Í²»»áÂÒ¸ãÁË¡£
ËùÒÔÈç¹ûÓõÄÓïÑÔÊÇphp£¬ÄÇôÔÚ´¦ÀíÒ³ÃæµÚÒ»ÐмÓÈ룺
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
header('Content-Type:text/html;charset=GB2312');
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
Èç¹ûÓõÄÓïÑÔÊÇasp£¬ÄÇôÔÚ´¦ÀíÒ³ÃæµÚÒ»ÐмÓÈ룺
£½£½£½£½£½£½£½£½£½£½£ ......
ÏÈ˵ͨ¹ýjavascript·¢ËÍʱµÄÂÒÂëÎÊÌ⣬Èç¹û·¢Ë͵ÄÊÇÖÐÎÄ£¬¾ÍÒªÓÃescapeÕâ¸öº¯Êý´¦Àí£¬±ÈÈ磺
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
var url="testurl.php?name="+"¸Õ¸Õ";
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
ÄÇô¾ÍÒª¸Ä³É
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
var url="testurl.php?name="+escape(¸Õ¸Õ);
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
ÏÂÃæ˵һϽÓÊÕʱµÄÂÒÂëÎÊÌ⣬ÓÃAJAXÀ´GET»ØÒ»¸öÒ³Ãæʱ£¬responsetextÀïÃæµÄÖÐÎĶà°ë»á³öÏÖÂÒÂ룬ÕâÊÇÒòΪXmlhttpÔÚ´¦Àí·µ»ØµÄresponseTextµÄʱºò£¬ÊÇ°ÑresposeBody°´UTF-8±àÂë½ø½âÂ뿼Ðγɵģ¬Èç¹û·þÎñÆ÷ËͳöµÄȷʵÊÇUTF-8µÄÊý¾ÝÁ÷µÄʱºòºº×Ö»áÕýÈ·ÏÔʾ£¬¶øËͳöÁËGBK±àÂëÁ÷µÄʱºò¾ÍÂÒÁË¡£½â¾öµÄ°ì·¨¾ÍÊÇÔÚËͳöµÄÁ÷ÀïÃæ¼ÓÒ»¸öHEADER£¬Ö¸Ã÷ËͳöµÄÊÇʲô±àÂëÁ÷£¬ÕâÑùXmlHTTP¾Í²»»áÂÒ¸ãÁË¡£
ËùÒÔÈç¹ûÓõÄÓïÑÔÊÇphp£¬ÄÇôÔÚ´¦ÀíÒ³ÃæµÚÒ»ÐмÓÈ룺
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
header('Content-Type:text/html;charset=GB2312');
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
Èç¹ûÓõÄÓïÑÔÊÇasp£¬ÄÇôÔÚ´¦ÀíÒ³ÃæµÚÒ»ÐмÓÈ룺
£½£½£½£½£½£½£½£½£½£½£ ......
×î½üÒ»Ö±ÔÚÑ°ÕÒÒ»¸ö±È½Ï·½±ãºÃÓõÄÊ÷¿Ø¼þ£¬MyTreeÊ÷¿Ø¼þ²¢Ã»ÓÐÌṩºÜ¶àÆäËûµÄ¹¦ÄÜ£¬µ«ÔÚAjaxÒì²½¼ÓÔؽڵãÉÏʵÏֵĺܼò½à£¬Áô×÷±¸Íü¡£
MyTreeµÄÏÂÔصØÖ·£ºhttp://www.itplus.com.cn/myTree/
ÏÂÔغó Demo£ºAjaxÒì²½¼ÓÔØÀý×Ó
Document£ºÎĵµ
myTree£º·ÅÏîÄ¿ÀïÒªÒýÓõÄÎļþ
MytreeTest.aspxÒ³
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MytreeTest.aspx.cs" Inherits="VistaToNewSchol.MytreeTest" %>
<!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" >
<head runat="server">
<title></title>
<script language="javascript" src="../myTree/myTree.js"></script>
<script language="javascript" src="../myTree/bingo.js"></script>
  ......
ÕÛÌÚÁ˺ó¤Ê±¼ä£¬ÖÕÓÚÔÚ½ñÌìÓÃJsTree²å¼þʵÏÖÁËAjaxÒì²½¼ÓÔؽڵãµÄ¹¦ÄÜ¡£
Zero.aspxÒ³£¬¸ÃÒ³ÓÃÓÚÏÔʾÊ÷¿Ø¼þ¡£
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Zero.aspx.cs" Inherits="VistaToNewSchol.Zero" %>
<!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" >
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/jquery.tree.js"></script>
<script type="text/javascript" >
$(function() {
& ......
±¾ÈË×î½ü¼òµ¥Ð´ÁËÒ»¸ö¶¯Ì¬È¡Êý¾ÝµÄµÄÒ»¸öAjax·½·¨£¬Ê¹ÓÃJquery×÷Ϊ¿ò¼Ü£¬Ë¼Â·ÈçÏ£ºÊ×ÏÈÀûÓúǫ́°ÑÊý¾Ý´æÈëÒ»¸ö¼òµ¥µÄ¼Çʱ¾ÎļþÖУ¬È»ºóAjax·ÃÎÊÒ»¸öWeb Ò³Ã棬WebÒ³Ãæ»ñÈ¡¼Çʱ¾ÎļþÄÚÈÝ£¬²¢·µ»ØÄÚÈݸøAjax£¬AjaxÊ×Ò³ÏÔʾÊý¾Ý¡£µ«ÊÇÓöµ½ÎÊÌâÁË£¬ÎÊÌâ¾ÍÊÇÖÐÎĵıàÂëÎÊÌâ¡£µ±ºǫ́ȡÊý¾Ý¸øAjax£¬AjaxÏÔʾÊý¾ÝµÄʱºò£¬ÔòJs±¨´í£¬ÏÔʾ»ùÓÚURIµÄ±àÂë´íÎó£¬ ÎÒÒ²ÎÊÁ˺ܶàÈË£¬²éÕÒÁËÐí¶à·½·¨£¬µ«ÊÇЧ¹û¶¼²»¼Ñ£¬ÁíÍâ³öÏÖÁËÒ»¸öÈÃÎÒ²»¿ÉÃ÷°×µÄÊ£¬ÎªÊ²Ã´ÓÐЩÖÐÎÄ×Ö±àÂëºó¾ÍÊÇÕýÈ·µÄ£¬¶øÓÐЩÖÐÎÄ×ÖÔò±¨´í£¬Íû´ó¼Ò°ïÎÒ½â¾öÏ£¡
´úÂëÈçÏ£º
Ò»¡¢ºǫ́½«Êý¾Ý´æÈëÎļþ
StreamWriter SW;
SW = File.CreateText(Server.MapPath("/info.txt"));
try
{
string str = "1,¼ì²â´úÂë";
SW.Write(str);
}
catch (System.Exception ex)
{
}
finally
{
SW.Close();
}
¶þ¡¢WebÒ³Ãæ»ñÈ¡ÎļþÊý¾Ý
string filename = Server.MapPath("/info.txt");
StreamReader sr = new StreamReader(filename, Encoding.Default);
str ......
1¡¢Çø¿éµÄÏÔʾÓëÒþ²Ø
ÔÚ½øÐÐajax±à³Ìʱ£¬¾³£»áÓõ½div±êÇ©¶ÔÒ³ÃæÔªËؽøÐв¼¾Ö£¬´óÖ·½·¨ÊÇ£¬°Ñ½çÃæ·Ö×ö¼¸´ó¿é£¬ÓÐʱºòÐèÒª¸ù¾Ýµã»÷²Ëµ¥ÏÔʾÏàÓ¦µÄ¿é¼°Òþ²ØÆäËû¿é£¬Õâʱ¿É¼òµ¥ÉèÖÃdiv.style.displayΪblock½øÐÐÏÔʾ£¬div.style.dispalyΪnone½øÐÐÒþ²Ø¡£
2¡¢½çÃæÔªËØÃüÃû
Ê×ÏÈ£¬½çÃæÔªËØÃüÃûÊDz»ÄÜÖظ´µÄ£¬Èç¹û±ØÐè¹²ÏíÔªËØÃû×Ö£¬Ôò¿ÉÒÔÔÚÏÔʾdiv¿éÇ°£¬°ÑÆäËûµÄdiv¿éµÄinnerHTMLÉèΪ“”£¬ÔÙÏÔʾ£¬¾Í¿É´ïµ½²»Í¬div¿éÄÚ²¿µÄÔªËØÃüÃû¹²Ïí¡£ ......
´Ë·½·¨ÓÃjspÄÚÖöÔÏóoutÊä³öµ½xmlÎļþÖÐ
public void ajaxEditorList() throws IOException{
HttpServletResponse response = ServletActionContext.getResponse();
//System.out.println("ddddddddddddddddddddddd;;;");
int unitid=Integer.parseInt(request.getParameter("unitid"));
//System.out.println("unitid:"+unitid);
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
unitinfolist=adminUnitInfoService.getKangarooUnitinfoListByunitid(unitid);
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
out.print("<?xml version=\"1.0\" encoding=\"GBK\"?>");
out.print("<unitinfoes>");
if(unitinfolist==null||unitinfoli ......