Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

AJAXÖÐÎÄÎÊÌâ[ת]

AJAXÖÐÎÄÎÊÌâ·ÖΪÁ½´óÀࣺ
1£©·¢ËÍ·¾¶ÖеIJÎÊýÓÐÖÐÎÄ£¬ÔÚ·þÎñÆ÷¶Î½ÓÊÕ²ÎÊýÖµÊÇÂÒÂë
ÀýÈ磺
var url="a.jsp?name=СÀî"£»
xmlHTTP.open ("post",url,true);
½â¾ö°ì·¨£º
ÀûÓÃjavascriptµÄÌṩµÄescape()»òencodeURI()·½·¨
ÀýÈ磺
¿Í»§¶Ë£º
var url="a.jsp?name=СÀî"£»
url=encodeURI(url);
url=encodeURI(url); //Á½´Î£¬ºÜ¹Ø¼ü[¾ßÌåΪʲô£¬ÎÒÒ²²»Çå³þ]
/********************************************/
Ò²ÓÐÈËд³Évar url="a.jsp?name=escape("СÀî")"£»
¹¦ÄܺÍencodeURI·½·¨ÀàËÆ¡£
/********************************************/
xmlHTTP.setrequestheader("cache-control","no-cache");
xmlHTTP.setrequestheader("Content-Type","application/x-www-form-urlencoded");
xmlHTTP.setrequestheader("contentType","text/html;charset=uft-8")//Ö¸¶¨·¢ËÍÊý¾ÝµÄ±àÂë¸ñʽ
xmlHTTP.open ("post",url,true);
·þÎñÆ÷¶Ë£º
String name = request.getParameter("name");
name = java.net.URLDecoder.decode("name", "UTF-8");
2£©·µ»ØÀ´µÄresponseText»òresponseXMLµÄÖµÖк¬ÓÐÖÐÎÄÊÇÂÒÂë
Ô­Òò£ºAJAXÔÚ½ÓÊÕresponseText»òresponseXMLµÄÖµµÄʱºòÊÇ°´ÕÕUTF-8µÄ¸ñʽÀ´½âÂëµÄ£¬Èç¹û·þÎñÆ÷¶Î·¢Ë͵ÄÊý¾Ý²»ÊÇUTF-8µÄ¸ñʽ£¬ÄÇô½ÓÊÕresponseText»òresponseXMLµÄÖµÓпÉÄÜΪÂÒÂë¡£
½â¾ö°ì·¨£ºÔÚ·þÎñÆ÷Ö¸¶¨·¢ËÍÊý¾ÝµÄ¸ñʽ£º
ÔÚjspÎļþÖУº
response.setContentType("text/text;charset=UTF-8");//·µ»ØµÄÊÇtxtÎı¾Îļþ
»òÊÇ
response.setContentType("text/xml;charset=UTF-8");//·µ»ØµÄxmlÎļþ
×ܽá:1)ajaxÌá½»Êý¾ÝµÄ¸ñʽĬÈÏΪutf-8,ÀûÓÃjavascriptµÄÌṩµÄescape()»òencodeURI()·½·¨.ÔÚ·þÎñÆ÷¶Ë½ÓÊÕµÄʱºòҪʹÓÃjava.net.URLDecoder.decode("","UTF-8")·½·¨½øÐнâÂë.
2)xtmlhttp ·µ»ØµÄÊý¾ÝĬÈϵÄ×Ö·û±àÂëÊÇutf-8,ËùÒÔ·þÎñÆ÷ÒªÏò¿Í»§¶Ë·¢ËÍÊý¾ÝµÄʱºò,Ò²Òª²ÉÓÃutf-8±àÂë
Èç¹ûÉÏÊö·½·¨ÈÔÈ»½â¾ö²»ÁËÂÒÂëÎÊÌâ,ÄÇÄã³¢ÊÔһϰÑjsp,htm,javaÎļþÓÃUTF-8±àÂë¸ñʽ±£´æ.
×ÜÖ®:Ç°ºǫ́Êý¾Ý½»»¥¶¼²ÉÓÃutf-8±àÂë¾ÍÐÐÁË.


Ïà¹ØÎĵµ£º

ÊղصÄÒ»¸öjs ajax·â×°Àà

Õâ¸öÀàÕª×Ô£º ASP.NET AjaxµäÐÍÓ¦Óà һÊé
xmlhttp.js
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      elem ......

¹ØÓÚAJAX¡¢B/S¡¢C/SµÄ¼¸¸ö˼¿¼


B/SΪºÎÄÑÓÚÌṩºÃµÄÓû§½»»¥ÌåÑé?
×î´óÎÊÌâÓм¸¸ö£º
¡¡¡¡(1)ÎÞ״̬µÄHTTPЭÒé
¡¡¡¡WINDOWS´°Ìå¼äÄܹ»Í¨¹ýÄÚ´æÖ±½Ó½»»»ÐÅÏ¢£¬µ«×÷ΪB/S¼Ü¹¹Í¨Ñ¶»ù´¡Ð­ÒéµÄHTTPÊÇÎÞ״̬µÄ¡£
¡¡¡¡Èç¹û½«ä¯ÀÀÆ÷¿´³ÉÊÇ¿ÍÈË£¬Web·þÎñÆ÷¿´³ÉÊÇÂùݣ¬ÔÚHTTPЭÒéµÄ¹ÜÀí֮ϣ¬»á³öÏÖÕâÖÖÇé¿ö£º²»¹Üij¿ÍÈËÀ´·Ã¶àÉٴΣ¬Web·þÎñÆ÷¶¼½«ÆäÊÓΪµ ......

ASP.NET AJAXµ÷ÓÃWebService

ÈçºÎÔÚ¿Í»§¶ËÖ±½Óµ÷ÓÃWebServiceÖеķ½·¨£¿
ÕâÀï½áºÏ¾­Ñé×Ô¼ºÐ´Ò»Ð´
1.Ê×ÏÈн¨Ò»¸ö ASP.NET AJAX-Enabled Web Site,ÕâÑùϵͳΪÎÒÃÇ×Ô¶¯ÅäÖúÃÁË»·¾³£¬ÕâÖ÷ÒªÌåÏÖÔÚWeb.configÕâ¸öÎļþÉÏ£¬Èç¹ûÒÑÓÐÍøÕ¾²»ÊÇASP.NET AJAX-Enabled Web SiteÒ²¿ÉÒÔ¶ÔÕÕÐÞ¸ÄÏÂWeb.config£¬Ò²¿ÉÒÔ´ïµ½ÏàͬµÄЧ¹û¡£
2.н¨Ò»¸öweb·þÎñ£¬WebSer ......

2009 12 28 ´«ÖDz¥¿Í—AJAX£¨×ÛºÏÁ·Ï°£©


½ñÌìÔçÉÏÀÏÙ¡½«×òÌìµÄÁ·Ï°½øÐÐÁ˽²½â¡£½ñÌìµÄÖ÷ÒªÄÚÈÝÊǶÔAJAXµÄ»ã×ÜÁ·Ï°£¬×öÁËÁ½¸öÁ·Ï°¶¼ÊDZȽϳ£Ê¹ÓõÄÓ¦Óá£
 
Ò»¡¢              ÏÂÀ­¿òµÄ¼¶Áª£¬±ÈÈ磬ѡÔñÏÂÀ­¿òÒ»ÖеÄÄÚÈÝ£¨³ÇÊÐÃû³Æ£©£¬ÔÚÏÂÀ­¿ò¶þÖÐÏÔʾÔÚÕâ¸ö³ÇÊÐÖеIJ¿ÃÅ¡£ÔÚÏÂÀ­ ......

AjaxÖÐsend·½·¨²ÎÊýµÄʹÓÃ

¡¡Ò»°ãÇé¿öÏ£¬Ê¹ÓÃAjaxÌá½»µÄ²ÎÊý¶àÊÇЩ¼òµ¥µÄ×Ö·û´®£¬¿ÉÒÔÖ±½ÓʹÓÃGET·½·¨½«ÒªÌá½»µÄ²ÎÊýдµ½open·½·¨µÄurl²ÎÊýÖУ¬´Ëʱsend·½·¨µÄ²ÎÊýΪnull¡£
ÀýÈç £º
¡¡¡¡ var url = "login.jsp?user=XXX&pwd=XXX";
¡¡¡¡xmlHttpRequest.open("GET",url,true);
¡¡¡¡xmlHttpRequset.send(null);
¡¡¡¡´ËÍ⣠......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ