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Àï²»ÓÃдÈκνâÂëµ
Ïà¹ØÎĵµ£º
11) ±íµ¥×ֶΰïÖúÐÅÏ¢µÄ×Ô¶¯Ìáʾ
ÔöÇ¿WEB±íµ¥µÄUsabilityÓкܶàºÜ¶àµÄ·½·¨£¬ÔÚÍøÉÏÒ»ËÑÒ»´óƬ£¬È»ºóÓÐЩʱºò£¬Óû§»á±»±íµ¥¸ãµÃºÜ»ìÂÒ£¬¶øÇÒ£¬²»Í¬µÄÓû§»á¶Ô±íµ¥Óв»Í¬µÄÀí½â£¬ÆäÊäÈëÒ²ÊÇǧÆæ°Ù¹Ö¡£ËùÒÔ£¬Îª±íµ¥×Ö¶ÎÔö¼ÓÒ»ÏÂ×Ô¶¯°ïÖúÐÅÏ¢µÄÌáʾ¾ø¶ÔÊǷdz£²»´íµÄÑ¡Ôñ¡£ÕâµãÔÚÌÔ±¦ÍøÉϱíÏֵñȽϳöÏÖ¡£ÏÂÃæÊÇÒ»¸ö·Ç³£¼òµ¥ ......
ÎÒÃÇ¿ÉÒÔʹÓÃXML×÷ΪÊý¾Ý´«ËÍ¡¢¹µÍ¨µÄ¸ñʽ£¬Ajax¿Í»§¶ËÈôÒª·¢ËÍXML£¬»ù±¾ÉϾÍÊǽ«XML×÷Ϊ×Ö·û´®£¬ÔÚPOSTÇëÇóʱ·¢ËÍ£¬ÀýÈ磺
*HelloAjax.js
view plaincopy to clipboardprint?
var xmlHttp;
function createXMLHttpRequest() {
if (window.XMLHttpRequest) {   ......
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLhTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new ......
ÄÚÈÝÒ³£º
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ScriptManagerProxyDemo.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javas ......