¼òµ¥ajax´úÂë¡£
<script type="text/javascript">
<!--
//½«Óû§ÊäÈëÒì²½Ìá½»µ½·þÎñÆ÷
function ajaxSubmit(){
//»ñÈ¡Óû§ÊäÈë
var question=document.forms[0].question.value;
//´´½¨XMLHttpRequest¶ÔÏó
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//´´½¨ÇëÇó½á¹û´¦Àí³ÌÐò
xmlhttp.onreadystatechange=function(){
if (4==xmlhttp.readyState){
if (200==xmlhttp.status){
var data=xmlhttp.responseText;
document.getElementById("result").innerHTML=data;
}else{
alert("error");
}
}
}
//´ò¿ªÁ¬½Ó£¬true±íʾÒì²½Ìá½»
xmlhttp.open("post", "/dict/servlet/dictAction", true);
//µ±·½·¨ÎªpostʱÐèÒªÈçÏÂÉèÖÃhttpÍ·
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
//·¢ËÍÊý¾Ý
xmlhttp.send("question="+question);
}
</script>
Ïà¹ØÎĵµ£º
¹ØÓÚajaxµÄÃû×Ö
ajax µÄÈ«³ÆÊÇAsynchronous JavaScript and XML£¬ÆäÖУ¬Asynchronous ÊÇÒì²½µÄÒâ˼£¬ËüÓбðÓÚ´«Í³web¿ª·¢ÖвÉÓõÄͬ²½µÄ·½Ê½¡£
¹ØÓÚͬ²½ºÍÒì²½
Òì²½´«ÊäÊÇÃæÏò×Ö·ûµÄ´«Ê䣬ËüµÄµ¥Î»ÊÇ×Ö·û£»¶øͬ²½´«ÊäÊÇÃæÏò±ÈÌصĴ«Ê䣬ËüµÄµ¥Î»ÊÇè壬Ëü´«ÊäµÄʱºòÒªÇó½ÓÊÜ·½ºÍ·¢ËÍ·½µÄʱÖÓÊ ......
¸½springÕûºÏDWR(°üº¬struts1,spring,hibernateÕûºÏÖÃ):
http://blog.csdn.net/jiabeis/archive/2010/05/26/5626121.aspx
×î½üÁ˽âÁËÒ»¸öÓÐÓõÄAJAX¹¤¾ß£¬¿´ÁËÍøÉϵÄÎÄÕÂÕâÀïÓÐһЩժ³ºÍ×Ô¼ºµÄ×ܽᣬºÍ´ó¼Ò·ÖÏí£º
ʲôÊÇDWR(Direct Web Remote)£¿
DWRÊÇÒ»ÖÖAJAX½â¾ö·½°¸£¡
DWR°üÀ¨Ò»¸öjava¿â£¬ÒÔ¼°Ò»Ì×javascript£¬Ê¹ ......
AJAX (Òì²½ JavaScript ºÍ XML) ÊǸöвúÉúµÄÊõÓï,רΪÃèÊöJavaScriptµÄÁ½ÏîÇ¿´óÐÔÄÜ.ÕâÁ½ÏîÐÔ
ÄÜÔÚ¶àÄêÀ´Ò»Ö±±»ÍøÂ翪·¢ÕßËùºöÂÔ,Ö±µ½×î½üGmail, Google suggestºÍgoogle MapsµÄºá¿Õ³öÊÀ²ÅʹÈË
ÃÇ¿ªÊ¼Òâʶµ½ÆäÖØÒªÐÔ.
ÕâÁ½Ïî±»ºöÊÓµÄÐÔÄÜÊÇ:
* ÎÞÐèÖØÐÂ×°ÔØÕû¸öÒ³Ãæ±ãÄÜÏò·þÎñÆ÷·¢ËÍÇëÇó.
* ¶ÔXMLÎĵµµÄ½âÎöºÍ´¦Àí£®
......
ÎÒÓÃ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 ......