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");
Ïà¹ØÎĵµ£º
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Ìá½»²ÎÊýÖмÓËæ»ú» ......
Ajax½éÉÜ
AJAX - ä¯ÀÀÆ÷Ö§³Ö
AJAX µÄÒªµãÊÇ XMLHttpRequest ¶ÔÏó¡£²»Í¬µÄä¯ÀÀÆ÷´´½¨ XMLHttpRequest ¶ÔÏóµÄ·½·¨ÊÇÓвîÒìµÄ¡£IE ä¯ÀÀÆ÷ʹÓà ActiveXObject£¬¶øÆäËûµÄä¯ÀÀÆ÷ʹÓÃÃûΪ XMLHttpRequest µÄ JavaScript ÄÚ½¨¶ÔÏó¡£ÈçÐèÕë¶Ô²»Í¬µÄä¯ÀÀÆ÷À´´´½¨´Ë¶ÔÏó£¬ÎÒÃÇҪʹÓÃÒ»Ìõ "try and catch" Óï¾ä¡£
<script type="t ......
µØÖ·£ºhttp://www.qhcar.cc/model/index.aspx?s=5£¬Õâ¸ö¾ÍÊÇǶÌ×ajax½á¹û¡£
http://www.qhcar.cc/model/index.aspx Õâ¸öÊǵ¥¸öµÄajax£¬
Óŵã¾ÍÊÇ¿ÉÒÔÓÃÒ»¸öÒ³ÃæʵÏÖÏÔʾȫ²¿³µÐͺͰ´¼¶±ðÑ¡Ôñ³µÐÍ£¬ÎªÁËÕչ˵¼º½ÉÏÃæÈç΢ÐͳµµÈÁ´½ÓÔÚ±ðµÄÒ³Ãæ½øÈ룬
http://www.qhcar.cc/model/index.aspx?s=5Õâ¸öµØÖ·²ÎÊýs£¬Åжϵ±s ......