AJAX ÎÞË¢ÐÂ
ICallbackEventHandler
aspx Ò³Ãæ£º
function CallServer(PhotoId)
{
document.getElementById("updatediv").style.display = "block";
document.getElementById("txtPhotoID").value = PhotoId;
var product = document.all("txtPhotoID").value;
<%= ClientScript.GetCallbackEventReference(this, "product", "ReceiveServerData",null)%>;
}
function ReceiveServerData(PhotoInfo)
{
if(PhotoInfo!="")
{
var result="";
var str=PhotoInfo;
var Photo=str.split("^&^");
for(i=0;i<Photo.length;i++)
{
result += Photo[i];
}
document.getElementById("txtPhotoName").value=Photo[0];
document.getElementById("txtPhotoDescr").value=Photo[1];
}else{("ÇëÑ¡ÔñÐèÒªÐ޸ĵÄÏàÆ¬£¡");}
}
.cs Ò³Ãæ
string ICallbackEventHandler.GetCallbackResult()
{
return Server.UrlDecode(CallBackValue)+"^&^"+Server.UrlDecode(CallPhotoColltion);
}
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
int PhotoID = int.Parse(eventArgument);
PhotoInfo = Photo.GetModel(PhotoID);
string PhotoName = PhotoInfo.PhotoName;
CallBackValue = Server.UrlDecode(PhotoName);
string PhotoIntroduction = PhotoInfo.PhotoIntroduction;
CallPhotoColltion = Server.UrlDecode(Phot
Ïà¹ØÎĵµ£º
½â¾öAJAX(JSP)ÖÐÎÄÂÒÂë»òÌØÊâ·ûºÅ£¨&£©µÄ´«µÝÎÊÌâ----> ±¾ÈËÔ´´£¨244796562@qq.com£©
************************js******************************
...
...
var s = encodeURIComponent("ÖÐÎÄ&English&@#$%!");
xmlReq.send("test", "txt=" + s, callback, callerror);//ͨ¹ýXMLHTTPRequest·¢ËÍ×Ö·ûÊý¾ ......
¼òµ¥µÄÃèÊöÏ DWR ÅäÖ㨱£ÃÜÐÒ飬Ôڴ˲»¹«¿ªÏîÄ¿Ãû³Æ£¬ÏîÄ¿Ïà¹ØÃû³ÆÈ«²¿ÓÃXXXX´úÌæ£©
Ê×ÏÈ ·Ï»°²»ËµÁË ´ó¼Ò¶¼Ó¦¸ÃÀí½âDWRµÄÓô¦ ²»¶®µÄÈ¥°Ù¶È
±ØÒª°ü DWR.JAR ¹Ù·½ÏÂÔØµØÖ·http://directwebremoting.org/dwr/download.html
Õâ¸öÏîÄ¿ÊÇÓÉ SSH+dwr+jquery+sitemesh+freemarker
WEB.XML
<!-- dwr -->
<serv ......
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript&quo ......
Ò»¡¢Ç°ÑÔ
´ò¿ª¹¤¾ßÏäµÄAjax extensions¿ÉÒÔ¿´µ½Îå¸öajax¿Ø¼þ£¬ÔÚvs2008ÖÐËüÃÇÒѾ¼¯³Éµ½ÁË.net framerwork3.5ÖУ¬Èç¹ûÊÇ֮ǰ°æ±¾µÄvsÔòÐèÒª×Ô¼ºÈ¥ÏÂÔØÎļþÀ´°²×°¡£ÕâÎå¸ö¿Ø¼þÔÚajaxÖÐÊǷdz£³£Óõģ¬ËùÒÔ΢Èí²Å½«ËûÃǼ¯³Éµ½vsÖÐÀ´£¬ÏÂÃæ½«¼òµ¥µÄ½éÉÜ×ÅÎå¸ö¿Ø¼þ¼°ËüÃǵÄÖØÒªÊôÐÔ¡£
¶þ¡¢ÖØÖÐÖ®ÖØ——Scrip ......