Ajax´«²ÎÖÐÎÄÂÒÂë
ÔÚAjax url´«²Îʱ³öÏÖÖÐÎÄÂÒÂëµÄÇé¿ö
Àý1: xmlHttp.open("GET","Engine.aspx?Action=getmainsort&Type=2&Parent="+escape("ÖÐÎÄ")+"&Stochastic=" + Math.random(),true);
µ«ÊÇÕâ¸öÖ»ÄÜÆÕͨµÄ<a href=''.ÓÐЧ¹û¡£Èç¹ûÊÇajax´«ÖµµÄ»°»¹ÊDz»ÐеÄ...ÓÐÈËÌá³ö:ÒªÓÃURIEncode±àÂë,È»ºóÔÚºǫ́½øÐнâÂë....µ«ÊÇÕâÑù×öÒ²ÊDz»ÐеÄ...
Àý2: url=user.do?content=encodeURI(encodeURI(con))
ºǫ́ :
URLDecoder.decode(request.getParameter("content"),"UTF-8");
ÕâÖÖ·½Ê½Ã²ËÆ¿ÉÒÔ,µ«ÊÇ»¹ÊÇÐèÒªÔÚºǫ́½âÂë,²»ÊÇ×îºÃµÄ·½°¸
ËÑË÷ºÜ¶à½â¾ö·½°¸,½á¹û¶¼Ò»Ñù»¹ÊDz»ÐÐ....½ÓÊܵ½µÄÖµ ʼÖÕ¶¼ÊÇÂÒÂë
×îºóÕÒµ½Ò»¸ö·½·¨:
Ò³ÃæÉÏ:
$.ajax({
type: "GET",
cache: false,
url: "/Role/validateRoleName?rolename="+encodeURIComponent($.trim($("#roleName").val())),
success: function(result) {
},
error: function() {
}
});
controllersÀï:
public JsonResult validateRoleName(string rolename)
{
...
}
ÔÚÒ³ÃæÉÏÖ»Ðè¸øÖÐÎÄֵתÂëencodeURIComponent("ÖÐÎÄ"),¶øÔÚcontrollersÀï²»ÓÃдÈκνâÂëµ
Ïà¹ØÎĵµ£º
×î½üÍøÉÏÌáµÄºÜ¶àµÄÒ»¸öиÅÄî¾ÍÊÇ AJAX ÁË, ÄÇô, AJAX ÊÇʲôÄØ? ÒÔÏÂÄÚÈÝÒýÓÃÍøÉÏ×ÊÁÏ:
AJAXÈ«³ÆΪ“Asynchronous JavaScript and XML”£¨Òì²½JavaScriptºÍXML£©£¬ÊÇÖ¸Ò»ÖÖ´´½¨½»»¥Ê½ÍøÒ³Ó¦ÓõÄÍøÒ³¿ª·¢¼¼Êõ¡£ËüÓлúµØ°üº¬ÁËÒÔϼ¸ÖÖ¼¼Êõ£º
Ajax£¨Asynchronous JavaScript + XML£©µÄ¶¨Òå
»ùÓÚ web±ê×¼£¨sta ......
11) ±íµ¥×ֶΰïÖúÐÅÏ¢µÄ×Ô¶¯Ìáʾ
ÔöÇ¿WEB±íµ¥µÄUsabilityÓкܶàºÜ¶àµÄ·½·¨£¬ÔÚÍøÉÏÒ»ËÑÒ»´óƬ£¬È»ºóÓÐЩʱºò£¬Óû§»á±»±íµ¥¸ãµÃºÜ»ìÂÒ£¬¶øÇÒ£¬²»Í¬µÄÓû§»á¶Ô±íµ¥Óв»Í¬µÄÀí½â£¬ÆäÊäÈëÒ²ÊÇǧÆæ°Ù¹Ö¡£ËùÒÔ£¬Îª±íµ¥×Ö¶ÎÔö¼ÓÒ»ÏÂ×Ô¶¯°ïÖúÐÅÏ¢µÄÌáʾ¾ø¶ÔÊǷdz£²»´íµÄÑ¡Ôñ¡£ÕâµãÔÚÌÔ±¦ÍøÉϱíÏֵñȽϳöÏÖ¡£ÏÂÃæÊÇÒ»¸ö·Ç³£¼òµ¥ ......
±¾ÀýÊDzÉÓÃJSP + Ajax + Îı¾À´ÑÝʾ¶àÑ¡¡¢È«Ñ¡£¬Ìí¼Ó¡¢É¾³ý¡¢¸üÐÂcheckbox¶àÑ¡¿òµÄЧ¹û£»³ä·ÖÕ¹ÏÖÁËÀûÓÃJavaScript¿ØÖÆHTML DOMÒÔ¼°ÀûÓÃXML http ´«µÝÊý¾Ý£¬ÀûÓÃJSP²Ù×÷Îı¾µÄЧ¹û¡£
¡¡¡¡1.JavaScript ÓÃÀ´¿ØÖÆÒ³ÃæÄÚÈݵÄÏÖʵÓëÔöɾЧ¹û£»
¡¡¡¡2.JSP×÷Ϊºǫ́£¬¶ÔÎı¾½øÐжÁÈ¡¡¢Ð´Èë¡¢¸üеȲÙ×÷£»
¡¡¡¡3.Îı¾¸ñʽÊÇÓÃÀ´´ ......
Js´úÂë
var url=Service.aspx?Value=' + escape(va);
obj=CreateAJAX();
if(obj)
& ......