Ajax ʵÏÖ
ÔÚÒѾ·¢²¼µÄ ASP.NET2.0 ÖУ¬ÎÞË¢ÐÂÒ³Ãæ¿ª·¢Ïà¹Ø²¿·Öͬ beta2 Óв»Éٸ͝¡£¶øÇÒÔÚÔ½À´Ô½¶àµÄ Ajax ¿ª·¢°ü±»¿ª·¢³öÀ´µÄÇé¿öÏ£¬ ASP.NET2.0 ×Ô´øµÄÎÞË¢ÐÂÒ³Ãæ¼¼ÊõûÓб»ºÜ¶àÈËÁ˽⣬ÉõÖÁ²»ÉÙÈËÈÏΪ¸Ã¹¦ÄÜÓÐЩ“¼¦Àß”¡£µ«Èç¹ûÎÒÃǽö½öÊÇÔÚ³ÌÐòÖмÓÈëºÜÉÙ²¿·ÖµÄ Ajax ÌØÐÔ£¬ Atlas ¡¢ Ajax.Net µÈ¾ÍÏÔµÃÓÐЩ“ɱ¼¦ÓÃÅ£µ¶”µÄ¸Ð¾õÁË¡£¶øÇÒ£¬ÎÒÈÏΪʹÓà ASP.NET2.0 ÌṩµÄ·½·¨½øÐпª·¢²¢²»ºÜ¸´ÔÓ£¬Ïà·´£¬Ê¹ÓúÜÉٵĴúÂë¾Í¿ÉÒÔ×ö³öÀ´ºÜ°ôµÄЧ¹û£¡
ÏÂÃæÎÒÀ´Ò»²½Ò»²½µÄ´ø´ó¼Ò¿ª·¢ÎÞˢеÄÒ³Ãæ£¡
µÚÒ»²½£ºÊµÏÖ ICallbackEventHandler ½Ó¿Ú
ICallbackEventHandler½Ó¿ÚλÓÚSystem.Web.UIÃüÃû¿Õ¼äÏ¡£ÔÚbeta2ʱ£¬ICallbackEventHandlerÖ»°üº¬Ò»¸öRaiseCallbackEvent·½·¨£¬¼´´¦Àí»Øµ÷ʼþ£¬ÓÖ·µ»Ø´¦Àí½á¹û¡£ÔÚÕýʽ°æÖУ¬Ëü±ä³ÉÁ˰üº¬GetCallbackResultºÍRaiseCallbackEventÁ½¸ö³ÉÔ±·½·¨£¬µÚÒ»¸öÓÃÀ´·µ»Ø»Øµ÷ʼþµÄ½á¹û£¬µÚ¶þ¸öÓÃÀ´³öÀ´»Øµ÷ʼþ¡£Õâ¸ö±ä»¯Ö÷ÒªÊÇΪÁ˱àдWeb¿Ø¼þ¶ø×öµÄ¸Ä¶¯£¬¾ßÌå¿ÉÒÔ¿´Ò»ÏÂGridViewµÈ¿Ø¼þÖеÄʵÏÖ´úÂë¡£
½¨Á¢Ò»¸ö Web ÍøÕ¾£¬ÎÒÃÇÀ´ÐÞ¸Ä default.aspx.cs Îļþ£º
1 public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
1 private string str;
2 public void RaiseCallbackEvent(string eventArgument)
3 {
4 //¿ÉÒÔ¸ù¾Ý´«µÝµÄ²ÎÊý²»Í¬£¬µ÷Óò»Í¬µÄ´¦ÀíÂß¼
5 str = "´Ó·þÎñÆ÷¶Ë·µ»ØµÄÄÚÈÝ£º" + eventArgument;
6 }
7
8 public string GetCallbackResult()
9 {
10 return str;
11 }
12
µÚ¶þ²½£º×¢²á»Øµ÷·½·¨
ÎÒÃÇÔÚ default.aspx Ò³ÃæÖÐÌí¼ÓÒ»¸ö TextBox £¬Ò»¸ö Label ºÍÒ»¸ö Html ¿Ø¼þ Button £¬²¢¸ø Button Ìí¼Ó onclick ʼþ£º
1 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
2 <input id="Button1
Ïà¹ØÎĵµ£º
ʹÓÃAjaxÎÞË¢ÐÂÉÏ´«ÎļþÊǵ±Ç°±È½ÏÁ÷ÐеŦÄÜ¡£½èÖúJQueryÇ¿´óµÄ²å¼þ£¬ÏÖÔÚÒѾ¿ÉÒÔºÜÈÝÒ×ÁË¡£
Ê×Ïȵ¼ÈëjsÎļþjquery.ajaxfileupload.js¡£´Ë²å¼þµÄÔÀíÊÇÔÚÎĵµÖд´½¨iframeºÍformÈ»ºóÔÚ½«ÎļþÉÏ´«µ½·þÎñÆ÷¡£
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head id="Head ......
<script type="text/javascript">
//¶¨ÒåXMLHttpRequest¶ÔÏó±äÁ¿
var xmlHttpRequest;
/*
* ´´½¨XMLHttpRequest¶ÔÏó¡£
* ±¾º¯ÊýÖ÷ÒªÍê³ÉXMLHttpRequest¶ÔÏóµÄ´´½¨£¬ºËÐÄ·ÖΪÒÔÏÂÁ½¸ö²¿·Ö£º
* µÚÒ»²½£ºÊ×ÏÈÅж ......
¹«Ë¾×î½ü¸øÎÒÒ»¸öÈÎÎñ£º°ÑÒ»¸öÓÃiframe×öµÄÁôÑÔ°å¸ÄдÓÃAjax×ö£¬ÕâÑù×öµÄÔÒòÊÇ£º¶ÔËÑË÷ÒýÇæµÄÓÅ»¯¡£ËäÈ»ºÜÔç¾ÍÖªµÀAjax¿ÉÒÔ×ö¾Ö²¿Ë¢Ð£¬µ«ÒòΪ×Ô¼ºÊǸձÏÒµÈëÖ°µÄ²ËÄñ£¬½ö½öÊÇÖªµÀÓÐÕâô¸ö¼¼Êõ¿ÉÒÔ×öÕâÑùÒ»¹¦ÄܶøÒÑ¡£Ò»±ßѧһ±ß×ö¡£ÏÖÔÚÕ⹦ÄÜ»¹Ã»ÍêȫŪºÃ£¬ÏÈ×ܽáÏÂ˼·ÒÔ±ã¸üºÃµÄѧϰ£º
ÒµÎñÂß¼£ºÔÚÏßÑÐÌֻᣬÌáÎÊÕßÒ³ ......
Ò»¸öajaxÇëÇóÒ»¸öjspÎļþ£¬²Ù×÷³É¹¦,jspÎļþout.println("1");µ«ÊÇÿ´Î³É¹¦ºóxmlHttp.responseText=='1'×ÜÊÇΪfalse£¬
ÓÃencodeURIComponent¿´xmlHttp.responseText£¬·¢ÏÖ×îºó¶àÁË%0A%0D£¬°Ù¶ÈһϠÓÃÀ´ÊÇ»»ÐУ¬
jspÎļþÖеÄout.println……°ÑlnÈ¥µôÔÙ´Î±È½Ï ³É¹¦ = =¡ ......
<mce:script type="text/javascript" language="javascript"><!--
function del(com_id,meet_id){
$.ajax({
url:'../company/meet.Ajax.php',
type:'POST',
data:{com_id:com_id,meet_id:meet_id},
dataType:"json",
timeout: 10 ......