DWR¿ª·¢AJAX ¼òµ¥Àý×Ó½éÉÜ
1£® Ê×ÏÈÏÂÔØ dwr.jar°ü£¬ÏÂÔصØÖ·: http://directwebremoting.org/dwr/
2£® ÔÚÓ¦ÓÃÖÐÒýÈë dwr.jar°ü
3£® ÐÞ¸Äweb.xmlÅäÖÃÎļþ
<servlet>
<servlet-name>dwr</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
ÏÂÃæ¾ÙÒ»¸öµäÐ͵ÄÀý×Ó£¬¼¶Áª²Ëµ¥
ʹÓÃdwr¿ÉÒÔÖ±½Óµ÷ÓÃij¸öÀàÖеÄij¸ö·½·¨
ÀýÈ磺
Õâ¸öÀý×Óµ÷ÓÃCommonListÀàÖÐgetPlanItem(String planId)·½·¨
×·¼ÓÒ»¸ödwr.xmlÅäÖÃÎļþ£¬ÈçÏ£º
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="CommonList">
<param name="class" value="com.edu.business.utils.CommonList"/>
</create>
<convert converter="bean" match="com.edu.business.common.beans.SelectListBean"/>
</allow>
</dwr>
JSPÒ³Ã棺
//µÃµ½ÏîÄ¿Ãû³Æ
function getPlanItem(){
CommonList.getPlanItemList(DWRUtil.getValue("PlanId"), callBack);
}
function callBack(lst){
DWRUtil.removeAllOptions("PlanItemId");
Ïà¹ØÎĵµ£º
XMLHttpRequest ¶ÔÏóÊÇAJAX¹¦ÄܵĺËÐÄ£¬Òª¿ª·¢AJAX³ÌÐò±ØÐë´ÓÁ˽âXMLHttpRequest ¶ÔÏó¿ªÊ¼¡£
Á˽âXMLHttpRequest ¶ÔÏó¾ÍÏÈ´Ó´´½¨XMLHttpRequest ¶ÔÏó¿ªÊ¼£¬ÔÚ²»Í¬µÄä¯ÀÀÆ÷Öд´½¨XMLHttpRequest ¶ÔÏóʹÓò»Í¬µÄ·½·¨£º
ÏÈ¿´¿´IE´´½¨XMLHttpRequest ¶ÔÏóµÄ·½·¨£¨·½·¨1£©£º
va ......
ÏÖÔÚÈç¹ûÄãÎʱðÈË“×î½üÁ½ÄêÔÚWeb¿ª·¢ÁìÓò×î»ðµÄ¼¼ÊõÊÇʲô”£¬AjaxÕâ¸ö´ÊÓ¦¸ÃÄÜÕ¼¾Ýһϯ֮µØ¡£È·Êµ£¬×Ô´Ó05Äêµ×±»Ìá³ö£¬Ajax¼¼Êõ¾ÍÒÔÄÑÒÔÏëÏóµÄËÙ¶ÈѸËÙºì±é´ó½Äϱ±£¬Êܵ½ÎÞÊýWeb¿ª·¢ÈËÔ±µÄÇàíùºÍ×·Åõ¡£¶ø¸÷ÖÖƽ̨ϵÄAjax¿ò¼Ü¸üÊÇÈçÓêºó´ºËñ°ãÏòÍâð£¬ÒÔÖÁÓÚÁ¬Î¢ÈíÕâÑùÈí¼þÒµµÄ¾ÞÍ·Ò²ÆȲ»¼°´ýÍƳö×Ô¼ºµÄ¿ò¼Ü&m ......
½ñÌì³õ´Î½Ó´¥AjaxÄÇôÎÒ½«ÎÒµÄѧϰ¼Ç¼ÏÂÀ´£¬×î½ü¼ÇÐÔ²»Ì«ºÃ¡£±¸Íü°É
1¡¢Ê×ÏÈ´ÓÍø·ÉÏÏÂÔØAjaxÀ©Õ¹°ü£¬VS2008Ö»ÊÇ´ø×Å×î»ù´¡µÄÈý¸öAjax¿Ø¼þ¡£ÄÇôÎÒÃÇÏÂÔØAjaxControlToolkit¿Ø¼þ£¬½«ÏÂÔغóµÄѹËõ°ü½âѹ¡£ÕÒ³öAjaxControlToolkit.dllËùÔÚλÖá£
2¡¢ÔÚVS2008ÖУ¬ËæÒâÕÒÒ»¸öÑ¡Ï£¬»òÕߣ¬Ð½¨Ò»¸öÑ¡ÏÀ´·ÅÈëÎÒÃÇËù¼ÓÈëµÄ ......
1£ºAjax¿ÉÒÔͨ¹ýJavaScriptµÄXMLHttpRequest¶ÔÏóÓë·þÎñÆ÷½øÐÐͨÐÅ£¬Í¨¹ýXMLHttpRequest£¬JavaScript¿ÉÒÔÔÚ²»ÖØÔØÒ³ÃæµÄÇé¿öÏÂÓë·þÎñÆ÷½øÐÐͨÐÅ¡£
2£ºXMLHttpRequest ä¯ÀÀÆ÷Ö§³Ö
<script type="text/javascript">
function ajaxFunction()
{
var xmlHttp;
try
{
xmlHtt ......
ÎÒÓÃPHPºÍAjax½áºÏ£¬Ìí¼ÓÊý¾ÝÖ®ºó£¬Ë¢ÐÂǰ̨ҳÃ棬Êý¾ÝûÓб仯¡£
ÎҸĶ¯PHP¶¯Ì¬½Å±¾£¬Ö»ÓÐÖØÐÂÕÒ¿ªIEÔÙÊäÈëµØÖ·£¬²ÅÄÜ¿´µ½Ð§¹û¡£
ÒÔÉÏÕâЩÊDz»ÊÇ»º´æµÄÔÒò°¡£¿Ôõô½â¾ö£¿
ajax»º´æÎÊÌâ½â¾ö;¾¶£º
ÊÇ»º´æµÄÎÊÌâ¡£
ÔÚ·þÎñ¶Ë¼Ó header("Cache-Control: no-cache, must-revalidate");
²¢ÇÒÔÚÄãµÄJSÌá½»²ÎÊýÖмÓËæ»ú» ......