Ajax¿çÓò·ÃÎÊ·½·¨´óÈ«
Case I. Web´úÀíµÄ·½Ê½ (on Server A)
¼´Óû§·ÃÎÊAÍøվʱËù²úÉúµÄ¶ÔBÍøÕ¾µÄ¿çÓò·ÃÎÊÇëÇó¾ùÌá½»µ½AÍøÕ¾µÄÖ¸¶¨Ò³Ã棬ÓɸÃÒ³Ãæ´úÌæÓû§Ò³ÃæÍê³É½»»¥£¬´Ó¶ø·µ»ØºÏÊʵĽá¹û¡£´Ë·½°¸¿ÉÒÔ½â¾öÏֽ׶ÎËùÄܹ»Ïëµ½µÄ¶àÊý¿çÓò·ÃÎÊÎÊÌ⣬µ«ÒªÇóAÍøÕ¾ÌṩWeb´úÀíµÄÖ§³Ö£¬Òò´ËAÍøÕ¾ÓëBÍøÕ¾Ö®¼ä±ØÐëÊǽôÃÜÐ×÷µÄ£¬ÇÒÿ´Î½»»¥¹ý³Ì£¬AÍøÕ¾µÄ·þÎñÆ÷¸ºµ£Ôö¼Ó£¬ÇÒÎÞ·¨´úÓû§±£´æsession״̬¡£
Case II. on-Demand·½Ê½ (on Server A)
MYMSNµÄÃÅ»§¾ÍÓõÄÕâÖÖ·½Ê½£¬²»¹ý MYMSNÖв»Éæ¼°¿çÓò·ÃÎÊÎÊÌâ¡£ÔÚÒ³ÃæÄÚ¶¯Ì¬Éú³ÉеÄ<mce:script type="text/javascript"><!--
£¬½«ÆäsrcÊôÐÔÖ¸Ïò±ðµÄÍøÕ¾µÄÍøÖ·£¬Õâ¸öÍøÖ··µ»ØµÄÄÚÈݱØÐëÊǺϷ¨µÄJavascript½Å±¾£¬³£ÓõÄÊÇJSONÏûÏ¢¡£´Ë·½°¸´æÔÚµÄȱÏÝÊÇ£¬ scriptµÄsrcÊôÐÔÍê³É¸Ãµ÷ÓÃʱ²ÉÈ¡µÄ·½Ê½Ê±get·½Ê½£¬Èç¹ûÇëÇóʱ´«µÝµÄ×Ö·û´®¹ý´óʱ£¬¿ÉÄÜ»áÎÞ·¨Õý³£ÔËÐС£²»¹ý´Ë·½°¸·Ç³£ÊʺϾۺÏÀàÃÅ»§Ê¹Óá£
<html>
<head>
<script language="javascript" type="text/javascript">
function loadContent()
{
var s=document.createElement('SCRIPT');
s.src='http://www.anotherdomain.com/TestCrossJS.aspx?f=setDivContent';
document.body.appendChild(s);
}
function setDivContent(v)
{
var dv = document.getElementById("dv");
dv.innerHTML = v;
}
// --></mce:script>
</head>
<body>
<div id="dv"></div>
<input type="button" value="Click Me" onclick="loadContent()">
</body>
</html>
ÆäÖеÄwww.anotherdomain.com/TestCrossJS.aspxÊÇÕâÑùµÄ£¬
<mce:script language="C#" runat="server"><!--
void Page_Load(object sender, EventArgs e)
{
string f = Request.QueryString["f"];
Response.Clear();
Response.ContentType = "application/x-javascript";
Response.Write(String.Format(@"
{0}('{1}');",
f,
DateTime.Now));
Response.End();
}
// --></mce:script>
µã»÷“Click Me”°´Å¥£¬Éú³ÉÒ»¸öеÄscript tag£¬ÏÂÔضÔÓ¦µÄ Javascript ½Å±¾£¬½áÊøʱ»Øµ÷ÆäÖеÄsetDivContent()£¬´Ó¶ø¸üÐÂÍøÒ³ÉÏÒ»¸ödivµÄÄÚÈÝ¡£
Case III. iframe·½Ê½ (on Server A)
²é¿´¹ýÐÑÀ´ÔÚjavaeyeÉϵÄһƪ¹ØÓÚ¿çÓò·ÃÎʵ
Ïà¹ØÎĵµ£º
ModalPopup ¿Ø¼þÔÊÐí½« Web Ò³ÃæÖеÄÒ»¸ö²¿·ÖÒÔÊÓ´°³ÌÐòÖеēģʽ”ÐÎʽÏÔ³öÀ´£¬Æðµ½ÌáʾÓû§²Ù×÷ºÍ±ÜÃâ¶ÔÒ³ÃæÖÐÆäËü²¿·ÖµÄÎó²Ù×÷µÄ×÷Óá£
“ģʽ”µÄÄÚÈÝ¿ÉÒÔÊÇÈÎÒâÒ»¸ö Control ÀàµÄÅÉÉú¿Ø¼þ£¬¿ª·¢ÈËÔ±¿ÉÒÔÖ¸¶¨µ±Ëü±»“ģʽ”ÏÔʾµÄʱºòµÄ±³¾°µÄÏÔʾÑùʽ¡£
µ±Ò»¸öÒ³Ãæ¿Ø¼þ±»&ld ......
½ñÌìС±àºÍ´ó¼Ò·ÖÏíµÄÊÇJSON²å¼þʵÏÖAjax£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
1£¬JSON»ù´¡ÖªÊ¶
JSON²å¼þÊÇStruts2µÄAjax²å¼þ£¬Í¨¹ýÀûÓÃJSON²å¼þ£¬ÔÊÐí¿ª·¢ÕßÒԷdz£Áé»î¼òµ¥µÄ·½Ê½À´¿ª·¢AjaxÓ¦Óá£
JSONµÄÈ«³ÆÊÇJavaSrcipt Object Notation,¼´JavaScript¶ÔÏó·ûºÅ,ËüÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»¸ñʽ.JSONµÄÊý¾Ý¸ñʽ¼ÈÊʺÏÈ ......
FlexÓÐרÓеıàÒë½âÎöÆ÷£¬ÓÉÓÚAJAXÉæ¼°µ½JAVASCRIPT¼¼Êõ£¬ËùÒÔ»¹ÊÇÃæ¶Ô¿çä¯ÀÀÆ÷µÄ·³ÈÅ¡£ajaxÔÚÒ³ÃæÉÏ´¦ÀíһЩ¼òµ¥Â߼ʱ£¬ÐèÒªÓÃJAVASCRIPTÀ´´¦Àí£¬Äã°²ÐĵÄÔÚÄãµÄä¯ÀÀÆ÷ÉϱàÒë½âÎöͨ¹ýÁË£¬ÄãÒÔΪ´ó¹¦¸ã³ÉÁË£¬¿ÉÊÇÊâ²»Öª£¬½Óõà¶øÀ´µÄÊÇ¿Í»§µÄͶËߣ¬ÒòΪÄãÔÒÔΪ³É¹¦µÄÒ³ÃæÔÚËûà ......
XMLHttpRequestÊÇXMLHTTP×é¼þµÄ¶ÔÏó£¬Í¨¹ýÕâ¸ö¶ÔÏó£¬Ajax¿ÉÒÔÏñ×ÀÃæÓ¦ÓóÌÐòÒ»Ñùֻͬ·þÎñÆ÷½øÐÐÊý¾Ý²ãµÄÐÅÏ¢½»»»£¬¶ø²»ÓÃÿ´Î¶¼Ë¢ÐÂÒ³Ã棬Ҳ²»ÓÃÿ´Î½«Êý¾Ý´¦ÀíµÄ¹¤×÷¶¼½»¸ø·þÎñÆ÷À´×ö£»ÕâÑù¼´¼õÇáÁË·þÎñÆ÷µÄ¸ºµ£ÓÖ¼Ó¿ìÁËÏìÓ¦Ëٶȡ¢Ëõ¶ÌÁËÓû§µÈ´ýµÄʱ¼ä¡£
XMLHttpRequestÊÇAjax¼¼ÊõÖÐ×î ......
¿´¿´ Ajax ºÍ DOM ½Å±¾±à³Ì¾¿¾¹Óжà¼òµ¥
ÎĵµÑ¡Ïî
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
¼¶±ð£º Öм¶
Jesse Skinner, Web ¿ª·¢ÈËÔ±, Freelance
2007 Äê 5 ÔÂ 16 ÈÕ
jQuery ÊÇÒ»¸öJavaScript ¿â£¬ËüÓÐÖúÓÚ¼ò»¯ JavaScript™ ÒÔ¼° Asynchronous JavaScript + XML (Ajax) ±à³Ì¡£ÓëÀàËÆµÄ JavaScript ¿â²»Í¬£¬jQuery ¾ßÓжÀ ......