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

AJAXÑéÖ¤Êý¾Ý²»Í¨¹ý,ÈçºÎÈÃÌá½»µÄ´úÂëÍ£Ö¹?

¸÷λ:

ÎÒÏëʵÏÖ:Óû§ÔÚµã»÷Ò³ÃæµÄÌá½»°´Å¥(server¶Ë°´Å¥),ÏÈͨ¹ýÒ³ÃæAJAX¼ì²éÒ³ÃæÊý¾Ý,ÔÙ¸ù¾ÝÑéÖ¤µÄ½á¹û¾ö¶¨ÊÇ·ñÌá½»Êý¾Ý(Ìá½»Êý¾ÝµÄ´úÂëÊÇͨ¹ýSERVER¶Ë´úÂëÌá½»µÄ.

ÎÒÓÃÒÔÏ·½·¨,·¢ÏÖϵͳʵÏÖ²»ÁË:

1.ÉèÖð´Å¥´¥·¢Ò»¸ö¿Í»§¶Ëµã»÷ʼþºÍÒ»¸ö·þÎñÆ÷µã»÷ʼþ(¿Í»§¶ËÆôÓÃAJAXÑéÖ¤,·þÎñÆ÷ÓÃ×÷Ìá½»Êý¾Ý),´úÂëÈçÏÂ:HTML code:
<asp:LinkButton ID="btSave" runat="server" Height="15px" Text="±£´æÐÅÏ¢" Visible="False" OnClick="btSave_Click" OnClientClick="return CheckFieldDataOnClient()" />

2.ÔÚ¿Í»§¶Ë´úÂëÖÐÆôÓÃAJAXµ÷ÓÃ,´úÂë¼ò»¯ÈçÏÂ:JScript code:
var xmlHttp;
var bCheckResult; //ÓÃ×÷ÅжÏAJAXÑéÖ¤½á¹ûµÄ²ÎÊý

function CheckFieldDataOnClient()
{
//´´½¨¼°´ò¿ªXMLHTTP,¼°·¢ËÍÇëÇó,¾ßÌå´úÂëÂÔ(Åųý´úÂë´íÎóµÄ¿ÉÄÜ)
//ÉèÖÃÑéÖ¤·µ»Øº¯Êý:OnReadyFunction
return bCheckResult ;
}

function OnReadyFunction()//½ÓÊÕXMLHTTPÑéÖ¤·µ»ØÊý¾ÝµÄº¯Êý
{
//½ÓÊÕÑéÖ¤Êý¾Ý,Èç¹ûÑé֤ͨ¹ý:
bCheckResult = true;
//Èç¹ûÑéÖ¤²»Í¨¹ý;
bCheckResult = false;
}


·þÎñÆ÷Ìá½»³ÌÐò:C# code:
protected int SaveData()
{
//Ìá½»Êý¾Ý.´úÂëÂÔ.


Ïà¹ØÎÊ´ð£º

[ÏòchinmoÌáÎÊ]Çë½ÌAJAX¼ÓÔØ¶¨Î»µÄÎÊÌâ

ÏÖÔÚÓÐÁ½¸öÒ³ÃæAºÍB£º

ÔÚAÒ³ÃæÓÐÒ»¸öÁ´½Ó£¬ÊÇB.aspx#commentµÄÐÎʽ

Ò²¾ÍÊǶ¨Î»BÒ³ÃæµÄêµã£¬¶øÇÒBÒ³ÃæµÄÄÚÈÝÊÇAJAX¼ÓÔØµÄ£¬

µ±¼ÓÔØÍê³ÉºóÎÞ·¨×¼È·¶¨Î»µ½Ãªµã£¬

¹À¼ÆÊÇÒ»´ò¿ªBÒ³ÃæÊ±Ò³Ãæ ......

AjaxÖлص÷º¯ÊýµÄ´¦Àí½á¹ûûÓзµ»Ø£¿

JScript code:

function callback() {
alert(18); //²âÊÔÊÇ·ñµ÷ÓÃÁËcallback»Øµ÷º¯Êý
if (httpRequest.readyState==4) {
if(httpRequest.status==200){
alert(3); //²âÊÔÊ ......

Ajax ÎÊÌâ

×î½üѧϰAJAX,²ÎÕÕhttp://dev.yesky.com/msdn/183/2426683.shtml×Ô¼º×öÁËÒ»¸öÁÐ×Ó£¬µ«ÊÇ×ÜÊÇÔÚJS´¦±¨´í_Default䶨Ò壬²»ÖªµÀʲôԭÒò¡£
Ç°Ì¨Ò³Ãæ£º
function comit_onclick()
{
¡¡var name=document. ......

AJAXÎÊÌ⣡£¡

Ò»¸öButton
Ò»¸öModalPopupExtender
Ò»¸öPanel

ÎÊÌâÊÇÕâÑùµÄ£ºÔÚ×öÐÞ¸Äʱºò µ±µãÐÞ¸ÄButton Panel ÏÔʾÁËÒ²ÓÐÒõӰЧ¹û£»
µ«ÊÇÎÒÐÞ¸ÄButtonÓÐbtn_Update_Clickʼþ£¬ÕâʼþÊǰó¶¨Êý¾ÝµÄ£»
ÏÖÔÚµÄÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ