AJAXʵÏÖloading¡.Ч¹û
ÂÌɫͨµÀÎļþ¶¼ÊÇ×ßÅú£¬Ò»¸öÎļþ×ßÍêÁ÷³Ìºó£¬ÔÙ²éѯ£¬ËÙ¶ÈÕæÊÇÂý£¬Òª·Ö±ð´Ó5¸ö±í²é£¬²¢ÇÒÐèÒªÉèÖùØÁª²éѯ£¬Òò´ËÔÚÌá½»Êý¾Ýºó£¬ÎÒÏ£Íû²éѯÕⲿ·Ö¿ÉÒÔÓÃAJAXʵÏÖ£¬µ±Êý¾Ýδ·µ»Øʱ£¬DIVÀïÏÔʾһ¸ö¼ÓÔØGIF£¬µÈÊý¾Ý·µ»ØºóÔÙÏÔʾÌá½»µÄÊý¾Ý¡£¶øÖظ´²éѯʱҲ²»»áÔÙÌá½»Êý¾ÝºÍË¢ÐÂ,½ÚÊ¡Á˺ܶà×ÊÔ´.
ËäÈ»ÎÒ»áÓÃDWR¿ò¼Ü£¬µ«ÊÇÎÒÈ´²»»áÓÃDWRʵÏÖÕâ¸ö¹¦ÄÜ£¬ÒòΪһֱûŪÇå³þDWRÊÇÔõô·â×°XMLHTTPµÄ£¬Òò´Ë»¹ÊÇÖ±½ÓÓÃXMLHTTPµÄÇëÇó״̬À´×ö±È½ÏÖ±¹Û¡£
[code]
<script type="text/javascript">
var xmlHttp;
//´´½¨Ò»¸öxmlHttpRequest¶ÔÏó
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function handleStateChange(){
var img = "<img src='/images/green/loading.gif' style='margin-top:130px; margin-left:250px'>";
if(xmlHttp.readystate == 4){ //±íʾÇëÇó״̬ 4ΪÍê³É
if(xmlHttp.status == 200){ //http״ָ̬ʾÂ룬200±íʾok
//½«·þÎñÆ÷·µ»ØÐÅÏ¢×÷ΪÎı¾²åÈëµ½DIVÈÝÆ÷ÖС£
document.getElementById("data").innerHTML = xmlHttp.responseText;
}
}
else document.getElementById("data").innerHTML = img;
//ÈôÏìӦδÍê³ÉµÄ»°£¬ÔòÏÔʾloading..
}
function showData(entityName){
var url = "/greengate.action?doing=listResult&entity_name="+entityName;
createXMLHttpRequest(
Ïà¹ØÎĵµ£º
jQueryÊÇÒ»¸ö¿ÉÒÔ¼ò»¯ JavaScript?ÒÔ¼°AJAX£¨Asynchronous JavaScript
+XML£¬Òì²½JavascriptºÍXML£©±à³ÌµÄJavascript¿â¡£²»Í¬ÓÚÆäËûµÄJavascript¿â£¬jQueryÓÐËû×Ô¼ºµÄÕÜѧ£¬Ê¹Äã¿É
ÒԺܼòµ¥µÄ±àд´úÂë¡£ÕâƪÎÄÕ¾ͻá´øÁìÄã¼ûʶһÏÂjQueryµÄÕÜѧ£¬Ì½ÌÖÒ»ÏÂËûµÄÌØÐÔÒÔ¼°¹¦ÄÜ£¬²¢ÇÒ»á×öһЩajaxµÄʾÀý£¬ÒÔ¼°ÈçºÎʹÓÃplug-
......
²ÉÓÃAjax´«µÝ²ÎÊý¼ÓºÅ(+)ºÍÓë·ûºÅ(&)ʱºò£¬·þÎñ¶Ë»ñÈ¡µ½µÄ²ÎÊý²¢²»ÈçÒ⣡
(1) "+"ºÅ£ºJavaScript½âÎöΪ×Ö·û´®Á¬½Ó·û£¬ËùÒÔ·þÎñÆ÷¶Ë½ÓÊÕÊý¾Ýʱ"+"»á¶ªÊ§¡£
(2)"&"£ºJavaScript½âÎöΪ±äÁ¿Á¬½Ó·û£¬ËùÒÔ·þÎñÆ÷¶Ë½ÓÊÕÊý¾Ýʱ&·ûºÅÒÔºóµÄÊý¾Ý¶¼»á¶ªÊ§¡£
½â¾ö°ì·¨£ºÔÚ´«µ½·þÎñ¶Ë֮ǰÏȽ«²ÎÊýÖеÄ"+"ºÍ"&"·ûºÅ¶¼± ......
//´´½¨XMLHttpRequest¶ÔÏó£¬ÐèÒª¸ù¾ÝIEºÍä¯ÀÀÆ÷ÀàÐÍ´´½¨²»Í¬µÄxhr¶ÔÏó
var xhrobj;
function check()
{
//»ñÈ¡Îı¾¿òµÄÖµ
var username = document.getElementById("username").value;
if(window.XMLHttpRequest)
{
//Õë¶Ôfirefox£¬Mozilla£¬ie7£¬ie8µÈ
xhrobj = new XMLHttpRequest();
/ ......
Ajax¿ÉÒÔʵÏÖÍøÒ³µÄ¾Ö²¿Ë¢ÐÂ,ÊÇͨ¹ýJS»ñÈ¡Êý¾Ý,ÔÙ°ÑÊý¾ÝÌí¼Óµ½ÍøÒ³ÖÐ,È»¶øÓÉÓÚä¯ÀÀÆ÷µÄ²»Í¬,³õѧÕߺÜÄÑ×öµ½¼æÈÝÎÊÌâ.
ÕâÀïÎÒÏò´ó¼Ò½éÉÜÒ»Öֺõķ½·¨.ͨ¹ýJQuery²å¼þ.JQuery.jsÎļþ¿ÉÒÔÔÚ¹ÙÍøÉÏÏÂÔØ,»òÕßgoogleÒ²ÐÐ.
Ê×ÏÈÄãÒªÔÚÍøÒ³ÒýÈëJSÎļþ
<script src="../javascript/jquery.js" type="text/javascript"></ ......
ÏîÄ¿ÖÐÏëÓÃajax
£¬ÓÚÊÇÔÚÍøÉÏ°ÇÁË
n
¶à×ÊÁÏ£¬·¸ÁË
n
¶à´íÎ󣬴ӽñÌìÉϰൽÏÖÔÚÒ»Ö±ÔÚ´¦ÀíÕâ¸öÎÊÌ⣬ÖÕÓÚ»¹ÊÇ°ÑËü½â¾öÁË¡£
µ±ÎÒ¿´µ½Ò³ÃæµÄajax
ÏÔʾºó£¬ÎÒÐË·ÜÒì³££¬ÎªÁ˼Ǽ×Ô¼ºÑ§Ï°µÄ
ajax
Àú³Ì£¬Ò²ÎªÁËÈøü¶àµÄÈËÉÙ×ßÍä·£¬ÌØд´ËÒ»ÎÄÒÔ¼ÇÖ®£¡
·Ï»°²»ËµÁË£¬ÎªÁ˸üºÃµÄÀí½â£¬ÎÒÖØ×öÁËÒ»¸öСµÄÏî ......