1.XMLHttpRequest¶ÔÏó
open("method","URL""[,asyncFlag[,"userName"[, "password"]]])
½¨Á¢¶Ô·þÎñÆ÷µÄ·ÃÎÊ¡£ÆäÖÐmethod²ÎÊý¿ÉÒÔʹÓÃGET¡¢POST¼°PUT£¬URL²ÎÊý¼È¿ÉÒÔʹÓþø¶ÔµØÖ·£¬Ò²¿ÉÒÔʹÓÃÏà¶ÔµØÖ·£¬´ËÍ⻹°üÀ¨Ó뽨Á¢Á¬½ÓÏà¹ØµÄÈý¸ö²ÎÊý
send(content) Ïò·þÎñÆ÷·¢ËÍÇëÇó
responseXML
·þÎñÆ÷½ø³Ì·µ»ØÊý¾ÝµÄ¼æÈÝ
DOM
µÄ
XML
Îĵµ¶ÔÏó
ResponseText ·þÎñÆ÷½ø³Ì·µ»ØÊý¾ÝµÄÎı¾£¬±íʾΪһ¸ö×Ö·û´®
eg: Óû§ÃÜÂëÑéÖ¤
<script
type="text/javascript">
var xmlhttpreq = false;
function createxmlhttprequest() {
...
}
//
·¢ËÍÇëÇóº¯Êý
function sendRequest(url) {
&nb ......
AJAXÊÇweb20µÄ»ùʯ£¬ÏÖÔÚÍøÉÏÁ÷Ðм¸ÖÖ¿ªÔ´µÄAJAX¿ò¼Ü£¬±ÈÈ磺jQuery,Mootools,Dojo,Ext JSµÈµÈ£¬ÄÇôÎÒÃǵ½µ×ÔÚʲôÇé¿öϸÃʹÓÃÄǸö¿ò¼Ü£¿ÒÔÏÂÊÇÒ»×éÕª³µÄÊý¾Ý£º
AjaxianÔÚ2007Äêµ×¶ÔAjax¹¤¾ß½øÐÐÁ˵÷²é£¬²¿·Öµ÷²é½á¹û¼ûÏÂ±í£¨ÆäÖÐÊý×ÖΪµ÷²éÕßʹÓøù¤¾ßµÄ°Ù·Ö±È£©£º
Prototype jQuery Ext Script.aculo.us Mootools YUI JSON Dojo Backbase
34.1% 29.3% 22.5% 22.3% 14.3% 13% 12.9% 11.8% 8.3%
ÆäÖÐPrototypeʹÓÃÂÊ×î¸ß£¬ºÜ´ó³Ì¶ÈÉÏÊÇÒòΪËüÊÇ×îÔç³ÉÊìµÄ¿ò¼Ü£¬ºÜ¶àÒÔÇ ......
×¢Òâ:
1¡¢<div id="iframe">ÏÔʾˢеÄÄÚÈÝ</div>
2¡¢µ÷ÓÃÒ첽ˢÐÂ:javascript:OnLink('µØÖ·')
<!--ajaxÒ첽ˢÐÂ-->
<script type="text/javascript">
//´´½¨XMLHttpRequestc¶ÔÏó
var xmlHttp=false;
//ÅжÏä¯ÀÀÆ÷
function createXMLHttpRequest(){
if(window.ActiveXObject){//IEä¯ÀÀÆ÷
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}else{//ÆäËûä¯ÀÀÆ÷£ºÈçmozilla µÄ fireFox(»ðºü) »òÕß netscape 7
xmlHttp=new XMLHttpRequest();
}
}
//Ìá½»»ñµÃÖµºóµÄ·½·¨
&nb ......
Google Search API
²Î¿¼Êé¼®£ºGoogle API´óÈ«—±à³Ì?¿ª·¢?ʵÀý
Êé¼®¶Ô¼¸Ê®ÖÖGoogle³£ÓÃAPI½øÐÐÁËÊáÀíºÍ½éÉÜ£¬¸¨ÒÔÐÐÖ®ÓÐЧµÄ´úÂëʵÀý
http://code.google.com/intl/zh-CN/apis/ajaxsearch/documentation/
1£©Google Site Search
GoogleÕ¾µãÄÚǶËÑË÷µÄʹÓ÷½·¨
<%@ page language="java" contentType="text/html; charset=GBK"%>
<html>
<head>
<title>Ê×Ò³</title>
</head>
<body>
Õ¾ÄÚÈ«ÎÄËÑË÷£¬¹È¸èºÏ×÷Ìṩ
<!-- SiteSearch Google -->
<form method="get" action="http://www.google.com/custom"
target="google_window">
<table border="0" bgcolor="#ffffff">
<tr>
<td nowrap="nowrap" valign="top" align="left" height="32"></td>
</tr>
<tr>
&nb ......
ASP.NET AJAXÈëÃÅϵÁн«»áд¹ØÓÚASP.NET AJAXһЩ¿Ø¼þµÄʹÓ÷½·¨ÒÔ¼°»ù´¡ÖªÊ¶£¬ÆäÖв¿·ÖÎÄÕÂΪԴ´£¬Ò²ÓÐһЩÎÄÕÂÊÇÖ±½Ó·Òë×Ô¹Ù·½Îĵµ£¬±¾²¿·ÖÄÚÈݻ᲻¶Ï¸üС£
Ŀ¼
ASP.NET AJAXÈëÃÅϵÁУ¨1£©£º¸ÅÊö
µ¼¶Á£º×÷Ϊ±¾ÏµÁÐÎÄÕµĿªÆª£¬¼òµ¥½éÉÜÒ»ÏÂASP.NET AJAXµÄ¸Å¿ö¼°¸÷¸ö×é³É²¿·Ö¡£
ASP.NET AJAXÈëÃÅϵÁУ¨2£©£ºÊ¹ÓÃScriptManager¿Ø¼þ
µ¼¶Á£ºScriptManager¿Ø¼þ°üÀ¨ÔÚASP.NET 2.0 AJAX ExtensionsÖУ¬ËüÓÃÀ´´¦ÀíÒ³ÃæÉϵÄËùÓÐ×é¼þÒÔ¼°Ò³Ãæ¾Ö²¿¸üУ¬Éú³ÉÏà¹ØµÄ¿Í»§¶Ë´úÀí½Å±¾ÒÔ±ãÄܹ»ÔÚJavaScriptÖзÃÎÊWeb Service£¬ËùÓÐÐèÒªÖ§³ÖASP.NET AJAXµÄASP.NETÒ³ÃæÉÏÓÐÇÒÖ»ÄÜÓÐÒ»¸öScriptManager¿Ø¼þ¡£ÔÚScriptManager¿Ø¼þÖÐÎÒÃÇ¿ÉÒÔÖ¸¶¨ÐèÒªµÄ½Å±¾¿â£¬»òÕßÖ¸¶¨Í¨¹ýJSÀ´µ÷ÓõÄWeb Service£¬ÒÔ¼°µ÷ÓÃAuthenticationServiceºÍProfileService£¬»¹ÓÐÒ³Ãæ´íÎó´¦ÀíµÈ¡£
ASP.NET AJAXÈëÃÅϵÁУ¨3£©£ºÊ¹ÓÃScriptManagerProxy¿Ø¼þ
µ¼¶Á£ºÔÚASP.NET AJAXÖУ¬ÓÉÓÚÒ»¸öASPXÒ³ÃæÉÏÖ»ÄÜÓÐÒ»¸öScriptManager¿Ø¼þ£¬ËùÒÔÔÚÓÐĸ°æÒ³µÄÇé¿öÏ£¬Èç¹ûÐèÒªÔÚMaster-PageºÍContent-PageÖÐÐèÒªÒýÈ벻ͬµÄ½Å±¾Ê±£¬Õâ¾ ......
ASP.NET AJAXÈëÃÅϵÁн«»áд¹ØÓÚASP.NET AJAXһЩ¿Ø¼þµÄʹÓ÷½·¨ÒÔ¼°»ù´¡ÖªÊ¶£¬ÆäÖв¿·ÖÎÄÕÂΪԴ´£¬Ò²ÓÐһЩÎÄÕÂÊÇÖ±½Ó·Òë×Ô¹Ù·½Îĵµ£¬±¾²¿·ÖÄÚÈݻ᲻¶Ï¸üС£
Ŀ¼
ASP.NET AJAXÈëÃÅϵÁУ¨1£©£º¸ÅÊö
µ¼¶Á£º×÷Ϊ±¾ÏµÁÐÎÄÕµĿªÆª£¬¼òµ¥½éÉÜÒ»ÏÂASP.NET AJAXµÄ¸Å¿ö¼°¸÷¸ö×é³É²¿·Ö¡£
ASP.NET AJAXÈëÃÅϵÁУ¨2£©£ºÊ¹ÓÃScriptManager¿Ø¼þ
µ¼¶Á£ºScriptManager¿Ø¼þ°üÀ¨ÔÚASP.NET 2.0 AJAX ExtensionsÖУ¬ËüÓÃÀ´´¦ÀíÒ³ÃæÉϵÄËùÓÐ×é¼þÒÔ¼°Ò³Ãæ¾Ö²¿¸üУ¬Éú³ÉÏà¹ØµÄ¿Í»§¶Ë´úÀí½Å±¾ÒÔ±ãÄܹ»ÔÚJavaScriptÖзÃÎÊWeb Service£¬ËùÓÐÐèÒªÖ§³ÖASP.NET AJAXµÄASP.NETÒ³ÃæÉÏÓÐÇÒÖ»ÄÜÓÐÒ»¸öScriptManager¿Ø¼þ¡£ÔÚScriptManager¿Ø¼þÖÐÎÒÃÇ¿ÉÒÔÖ¸¶¨ÐèÒªµÄ½Å±¾¿â£¬»òÕßÖ¸¶¨Í¨¹ýJSÀ´µ÷ÓõÄWeb Service£¬ÒÔ¼°µ÷ÓÃAuthenticationServiceºÍProfileService£¬»¹ÓÐÒ³Ãæ´íÎó´¦ÀíµÈ¡£
ASP.NET AJAXÈëÃÅϵÁУ¨3£©£ºÊ¹ÓÃScriptManagerProxy¿Ø¼þ
µ¼¶Á£ºÔÚASP.NET AJAXÖУ¬ÓÉÓÚÒ»¸öASPXÒ³ÃæÉÏÖ»ÄÜÓÐÒ»¸öScriptManager¿Ø¼þ£¬ËùÒÔÔÚÓÐĸ°æÒ³µÄÇé¿öÏ£¬Èç¹ûÐèÒªÔÚMaster-PageºÍContent-PageÖÐÐèÒªÒýÈ벻ͬµÄ½Å±¾Ê±£¬Õâ¾ ......
Ajax(Asynchronous JavaScript and XML)˵µ½µ×¾ÍÊÇÒ»ÖÖä¯ÀÀÆ÷Òì²½¶ÁÈ¡·þÎñÆ÷ÉÏXMLÄÚÈݵļ¼Êõ¡£ÏÖÔڵļ¼Êõ·²ÊǸúXML³¶ÉϹØϵ£¬ÔÙ¼ÓÉϸö¸ÅÄî×ö»Ï×Ó£¬¾ÍÏñ½ð×°ÁËÒ»Ñù£¬×§µÃ²»ÐС£ÃÅÍâ µÄÈË¿´µÃºÜÊÇÈÈÄÖ£¬ÃÅÀïµÄÈËÒ¡Ò¡Í·²»ÍâÈçÊÇ¡£XMLÄØ£¬¿çƽ̨µÄг±ÓïÑÔ£¿ÆäʵXML£½TXT¡£
XMLÖ»ÊÇ·ûºÏºÜ¶à¹æ·¶µÄÎı¾¡£Ëü±¾Éíʲô¶¼²»ÊÇ£¬Ö»ÊDZ£ ´æ×Ö·ûµÄÎļþ¡£¶øä¯ÀÀÆ÷Òì²½¶ÁÈ¡µÄÖ»ÊÇ·þÎñÆ÷ÉϵÄÎı¾ÄÚÈÝ£¬ËùÒÔÔÚAjax¿ª·¢Ê±ÍêÈ«²»±Ø¾ÐÄàÓÚXML¡£[°æȨËùÓУ¬www.jialing.net]
JSONµÄÀ´Àú
XML µÄ×÷ÓÃÊǸñʽ»¯Êý¾ÝÄÚÈÝ¡£Èç¹ûÎÒÃDz»ÓÃXML»¹ÓÐʲô¸üºÃµÄ·½·¨Âð£¿Õâ¸ö´ð°¸ÊÇJSON¡£½éÉÜJSON֮ǰÎÒÏȽéÉÜÒ»ÏÂJavaScriptÕâÃŽű¾Óï ÑÔ¡£½Å±¾ÓïÑÔ×ÔÉíÓж¯Ì¬Ö´ÐеÄÌ츳¡£¼´ÎÒÃÇ¿ÉÒÔ°ÑÏëÒªÖ´ÐеÄÓï¾ä·ÅÔÚ×Ö·û´®Àͨ¹ýeval()Õâ¸ö¶¯Ì¬Ö´Ðк¯ÊýÀ´Ö´ÐС£×Ö·û´®ÀïµÄÄÚÈÝ»áÏñÎÒÃÇдµÄ½Å±¾ Ò»Ñù±»Ö´ÐС£
ʾÀý1£º
<HTML>
<HEAD>
<TITLE>eval example 1</TITLE>
</HEAD>
<BODY>
<script>
str = "alert('hello')";
eval(str);
</script>
</BODY>
</HTML>
´ò¿ªÒ³Ãæ»áµ¯³öhello´°¿Ú¡£
ÎÒÃÇ¿ÉÒÔÔÚ×Ö·û´®ÖзÅÈκνű¾Óï¾ä£¬°üÀ¨ÉùÃ÷Óï¾ ......
Ajax(Asynchronous JavaScript and XML)˵µ½µ×¾ÍÊÇÒ»ÖÖä¯ÀÀÆ÷Òì²½¶ÁÈ¡·þÎñÆ÷ÉÏXMLÄÚÈݵļ¼Êõ¡£ÏÖÔڵļ¼Êõ·²ÊǸúXML³¶ÉϹØϵ£¬ÔÙ¼ÓÉϸö¸ÅÄî×ö»Ï×Ó£¬¾ÍÏñ½ð×°ÁËÒ»Ñù£¬×§µÃ²»ÐС£ÃÅÍâ µÄÈË¿´µÃºÜÊÇÈÈÄÖ£¬ÃÅÀïµÄÈËÒ¡Ò¡Í·²»ÍâÈçÊÇ¡£XMLÄØ£¬¿çƽ̨µÄг±ÓïÑÔ£¿ÆäʵXML£½TXT¡£
XMLÖ»ÊÇ·ûºÏºÜ¶à¹æ·¶µÄÎı¾¡£Ëü±¾Éíʲô¶¼²»ÊÇ£¬Ö»ÊDZ£ ´æ×Ö·ûµÄÎļþ¡£¶øä¯ÀÀÆ÷Òì²½¶ÁÈ¡µÄÖ»ÊÇ·þÎñÆ÷ÉϵÄÎı¾ÄÚÈÝ£¬ËùÒÔÔÚAjax¿ª·¢Ê±ÍêÈ«²»±Ø¾ÐÄàÓÚXML¡£[°æȨËùÓУ¬www.jialing.net]
JSONµÄÀ´Àú
XML µÄ×÷ÓÃÊǸñʽ»¯Êý¾ÝÄÚÈÝ¡£Èç¹ûÎÒÃDz»ÓÃXML»¹ÓÐʲô¸üºÃµÄ·½·¨Âð£¿Õâ¸ö´ð°¸ÊÇJSON¡£½éÉÜJSON֮ǰÎÒÏȽéÉÜÒ»ÏÂJavaScriptÕâÃŽű¾Óï ÑÔ¡£½Å±¾ÓïÑÔ×ÔÉíÓж¯Ì¬Ö´ÐеÄÌ츳¡£¼´ÎÒÃÇ¿ÉÒÔ°ÑÏëÒªÖ´ÐеÄÓï¾ä·ÅÔÚ×Ö·û´®Àͨ¹ýeval()Õâ¸ö¶¯Ì¬Ö´Ðк¯ÊýÀ´Ö´ÐС£×Ö·û´®ÀïµÄÄÚÈÝ»áÏñÎÒÃÇдµÄ½Å±¾ Ò»Ñù±»Ö´ÐС£
ʾÀý1£º
<HTML>
<HEAD>
<TITLE>eval example 1</TITLE>
</HEAD>
<BODY>
<script>
str = "alert('hello')";
eval(str);
</script>
</BODY>
</HTML>
´ò¿ªÒ³Ãæ»áµ¯³öhello´°¿Ú¡£
ÎÒÃÇ¿ÉÒÔÔÚ×Ö·û´®ÖзÅÈκνű¾Óï¾ä£¬°üÀ¨ÉùÃ÷Óï¾ ......
×ܼǼÊý:703; ×ÜÒ³Êý:118; ÿҳ6 Ìõ;
Ê×Ò³ ÉÏÒ»Ò³ [3] [4] [5] [6] 7
[8] [9] [10] [11] [12] ÏÂÒ»Ò³ βҳ