ajaxµÄÁбíÁª¶¯Ê¾Àý
ajaxµÄÁбíÁª¶¯Ê¾Àý
1¡¢ ÊäÈëÓò£º
ÇëÑ¡ÔñÊ¡£º
<select id="sel1" onchange="return choose(this);">
<option value="">--ÇëÑ¡Ôñ--</option>
<option value="1">ºþÄÏÊ¡</option>
<option value="2">ºþ±±Ê¡</option>
</select>
ÇëÑ¡ÔñÊУº
<select id="sel2">
<option value="">--ÇëÑ¡Ôñ--</option>
</select>
2¡¢ JavaScript½Å±¾£º
var xmlHttp;
//´´½¨XMLHttpRequest¶ÔÏó
function createXMLHttpRequest() {
if(window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpReuqest();
}
}
//Ñ¡ÔñÏÂÁÐÁбíÖеÄÖµ
function choose(obj) {
var province = obj.value;
createXMLHttpRequest();
xmlHttp.onreadystatechange = process;
xmlHttp.open("GET", "SelProvince?province=" + province);
xmlHttp.send(null);
}
//ÓÃÀ´´¦Àí״̬¸Ä±äµÄº¯Êý
function process() {
//¶¨ÒåÒ»¸ö±äÁ¿ÓÃÓÚ´æ·Å´Ó·þÎñÆ÷·µ»ØµÄÏìÓ¦½á¹û
var result;
if(xmlHttp.readyState == 4) { //Èç¹ûÏìÓ¦Íê³É
&
Ïà¹ØÎĵµ£º
PopupControlÀ©Õ¹Æ÷¿Ø¼þ¿ÉÒÔ¸½¼Óµ½ÈκοؼþÖ®ÉÏ£¬µ±Óû§µã»÷¸Ã¿Ø¼þʱ£¬½«µ¯³öÒ»¸öÔ¤ÏÈÖ¸¶¨ºÃµÄ¡¢ÏÔʾ¸½¼ÓÐÅÏ¢»òÓÃÀ´°ïÖúÓû§Ö´ÐÐijЩÉ趨µÄPanel¡£µ±¸Ã¿Ø¼þʧȥÊäÈë½¹µãÖ®ºó£¬Panel½«×Ô¶¯Ïûʧ£¬ÇÒÓû§ÔÚÆäÖнøÐеÄÅäÖý«±»É趨µ½À©Õ¹Æ÷µÄÄ¿±ê¿Ø¼þÖ®ÉÏ¡£
ʵ ......
var jsonObj;
var xmlhttp = null;
function callAsync(url, callbackSuccess)
{
xmlhttp = new Ajax();
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange=function()
{
// readyState = 4 ; "complete"
if (xmlhttp.readyState==4)
{ ......
±¾ÎÄÄÚÈÝÕª×Ô£º¡¶Java Web¿ª·¢½Ì³Ì——ÈëÃÅÓëÌá¸ßƪ£¨JSP+Servlet£©¡·
½»»¥µÄ»ù±¾¹ý³Ì°üÀ¨£º
l ´´½¨XMLHttpRequest¶ÔÏó£»
l ·¢ËÍÇëÇó£»
l ´¦ÀíÏìÓ¦¡£
´ ......
ÔÚÕâ¸ö±»Ajax¼¼ÊõͳÖεĻ¥ÁªÍøʱ´ú£¬ºÜ¶àAjax³ÌÐò¶¼»áÔÚÒì²½¶ÁÈ¡Êý¾ÝµÄͬʱ£¬ÏÔʾһ¸öÕýÔÚ¶ÁÈ¡»òLoadingµÄ¶¯»£¬½ñÌì±òGoÒªÏò´ó¼Ò
ÍƼöÒ»¸öÔÚÏßÉú³ÉLoadingÔ¤Ôض¯»GifͼƬµÄÍøÕ¾£¬Ëü²»µ«ÌṩÁ˳¬¶àµÄLoading¶¯»Ñùʽ¹©ÄãÑ¡Ôñ£¬¶øÇÒÄ㻹¿ÉÒÔ×Ô¶¨Òå³ß´ç¡¢ÑÕÉ«µÈ²ÎÊý£¬¿É
ν·½±ãµ½¼Ò£¬×î×îÖØÒªµÄÊÇ£¬PreLoaders.net
Ìṩ ......
ajax½øÐÐÓû§µÄÓÐЧÐÔ¼ì²âʾÀý
1¡¢ ÊäÈëÓò£º
»áÔ±µÄÓÐЧÐÔ¼ì²é£º
<input type="text" name="username"> <input type="button" value="¼ì²é" onclick="return check();">
2¡¢ JavaScript½Å±¾£º
var xmlHttp;
//´´½¨XMLHttpRequest ......