Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

AJAX (Òì²½ JavaScript ºÍ XML)

AJAX (Òì²½ JavaScript ºÍ XML) ÊǸöвúÉúµÄÊõÓï,רΪÃèÊöJavaScriptµÄÁ½ÏîÇ¿´óÐÔÄÜ.ÕâÁ½ÏîÐÔ
ÄÜÔÚ¶àÄêÀ´Ò»Ö±±»ÍøÂ翪·¢ÕßËùºöÂÔ,Ö±µ½×î½üGmail, Google suggestºÍgoogle MapsµÄºá¿Õ³öÊÀ²ÅʹÈË
ÃÇ¿ªÊ¼Òâʶµ½ÆäÖØÒªÐÔ.
ÕâÁ½Ïî±»ºöÊÓµÄÐÔÄÜÊÇ:
* ÎÞÐèÖØÐÂ×°ÔØÕû¸öÒ³Ãæ±ãÄÜÏò·þÎñÆ÷·¢ËÍÇëÇó.
* ¶ÔXMLÎĵµµÄ½âÎöºÍ´¦Àí£®
²½Öè 1 – "Çë!" --- ÈçºÎ·¢ËÍÒ»¸öHTTPÇëÇó
ΪÁËÓÃJavaScriptÏò·þÎñÆ÷·¢ËÍÒ»¸öHTTPÇëÇó, ÐèÒªÒ»¸ö¾ß±¸ÕâÖÖ¹¦ÄܵÄÀàʵÀý.
ÕâÑùµÄÀàÊ×ÏÈÓÉInternet ExplorerÒÔActiveX¶ÔÏóÒýÈë, ±»³ÆΪXMLHTTP. ºóÀ´Mozilla, Safari ºÍÆäËû
ä¯ÀÀÆ÷·×·×·ÂЧ, ÌṩÁËXMLHttpRequestÀà,ËüÖ§³Ö΢ÈíµÄActiveX¶ÔÏóËùÌṩµÄ·½·¨ºÍÊôÐÔ.
Òò´Ë, ΪÁË´´½¨Ò»¸ö¿çä¯ÀÀÆ÷µÄÕâÑùµÄÀàʵÀý(¶ÔÏó), ¿ÉÒÔÓ¦ÓÃÈçÏ´úÂë:
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
(ÉÏÀý¶Ô´úÂë×öÁËÒ»¶¨¼ò»¯,ÕâÊÇΪÁ˽âÊÍÈçºÎ´´½¨XMLHTTPÀàʵÀý.
ʵ¼ÊµÄ´úÂëʵÀý¿É²ÎÔı¾Æª²½Öè3.)
Èç¹û·þÎñÆ÷µÄÏìӦûÓÐXML mime-type header,ijЩMozillaä¯ÀÀÆ÷¿ÉÄÜÎÞ·¨Õý³£¹¤×÷. ΪÁ˽â¾öÕâ¸ö
ÎÊÌâ, Èç¹û·þÎñÆ÷ÏìÓ¦µÄheader²»ÊÇtext/xml,¿ÉÒÔµ÷ÓÃÆäËü·½·¨Ð޸ĸÃheader.
http_request = new XMLHttpRequest();
http_request.overrideMimeType('text/xml');
½ÓÏÂÀ´Òª¾ö¶¨µ±ÊÕµ½·þÎñÆ÷µÄÏìÓ¦ºó,ÐèÒª×öʲô.ÕâÐèÒª¸æËßHTTPÇëÇó¶ÔÏóÓÃÄÄÒ»¸öJavaScriptº¯Êý
´¦ÀíÕâ¸öÏìÓ¦.¿ÉÒÔ½«¶ÔÏóµÄonreadystatechangeÊôÐÔÉèÖÃΪҪʹÓõÄJavaScriptµÄº¯ÊýÃû,ÈçÏÂËùʾ:
http_request.onreadystatechange = nameOfTheFunction;
×¢Òâ:ÔÚº¯ÊýÃûºóûÓÐÀ¨ºÅ,Ò²ÎÞÐè´«µÝ²ÎÊý.ÁíÍ⻹ÓÐÒ»ÖÖ·½·¨,¿ÉÒÔÔÚìéÒ³(fly)Öж¨Ò庯Êý¼°Æä¶Ô
ÏìÓ¦Òª²ÉÈ¡µÄÐÐΪ,ÈçÏÂËùʾ:
http_request.onreadystatechange = function(){
// do the thing
};
ÔÚ¶¨ÒåÁËÈçºÎ´¦ÀíÏìÓ¦ºó,¾ÍÒª·¢ËÍÇëÇóÁË.¿ÉÒÔµ÷ÓÃHTTPÇëÇóÀàµÄopen()ºÍsend()·½·¨, ÈçÏÂËùʾ:
http_request.open('GET', 'http://www.example.org/some.file', true);
http_request.send(null);
* open()µÄµÚÒ»¸ö²ÎÊýÊÇHTTPÇëÇó·½Ê½ – GET, POST, HEAD »òÈκηþÎñÆ÷ËùÖ§³ÖµÄÄúÏëµ÷Óõķ½Ê½
. °´ÕÕHTTP¹æ·¶,¸Ã²ÎÊýÒª´óд;·ñÔò,ijЩä¯ÀÀÆ÷(ÈçFirefox)¿ÉÄÜÎÞ·¨´¦ÀíÇëÇó.ÓйØHTTPÇëÇó·½·¨µÄÏê
ϸÐÅÏ¢¿É²Î¿¼


Ïà¹ØÎĵµ£º

javascript¿çä¯ÀÀÆ÷´´½¨XML¶ÔÏó


var
 
xmlDoc
 
=
 
null
;
function
 
parseXML
(
xmlUrl
)
{
¡¡¡¡try
 
{
¡¡¡¡¡¡¡¡//IE
¡¡¡¡¡¡¡¡xmlDoc
 
=
 
new
 
ActiveXObject
(
"Microsoft.XMLDOM"
);
¡¡¡¡¡¡¡¡xmlDoc
.
async
 
=
 
false
;
¡¡¡¡¡¡¡¡xmlDoc ......

JavaScriptʼþ´óÈ«

JavaScriptʼþ´óÈ«
 
 
click() ¶ÔÏó.click() ʹ¶ÔÏó±»µã»÷¡£
closed ¶ÔÏó.closed ¶ÔÏó´°¿ÚÊÇ·ñÒѹرÕtrue/false
clearTimeout(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetTimeout¶ÔÏó
clearInterval(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetInterval¶ÔÏó
confirm("ÌáʾÐÅÏ¢") µ¯³öÈ·ÈÏ¿ò£¬È·¶¨·µ»ØtrueÈ¡Ïû·µ»Øfalse
cursor:Ñùʽ ¸ü¸ÄÊó±êÑùÊ ......

javascript typeofÓ¦ÓÃ

typeof ÊÇJavaScriptµÄÔËËã·û
    ——·µ»ØÒ»¸öÓÃÀ´±íʾ±í´ïʽµÄÊý¾ÝÀàÐ͵Ä×Ö·û´®
   typeof[(] expression [)]  //typeofÓï·¨ÖеÄÔ²À¨ºÅÊÇ¿ÉÑ¡Ïî
  typeof ÔËËã·û@import url(../html-vss/msdnie4a.css);
typeof
ÔËËã·û°ÑÀàÐÍÐÅÏ¢µ±×÷×Ö·û´®·µ»Ø¡£typeof
·µ»ØÖµÓÐÁ ......

java ×Ô¼º×öµÄ¶ÔXMLÎļþµÄ¶Áд²Ù×÷

XMLÎļþʵÀý£º
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource auth="Container" maxActive="20" name="sss" password="123"
type="javax.sql.DataSource" />
<Resource auth="Container" ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ