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Öв»Éæ¼°¿çÓò·ÃÎÊÎÊÌâ¡£ÔÚÒ³ÃæÄÚ¶¯Ì¬Éú³ÉеÄ<script>£¬½«Æä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;
}
</script>
</head>
<body>
<div id="dv"></div> <input type="button" value="Click Me" onclick="loadContent()">
</body>
</html> ÆäÖеÄwww.anotherdomain.com/TestCrossJS.aspxÊÇÕâÑùµÄ£¬
<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();
}
&l
Ïà¹ØÎĵµ£º
ÔÚʹÓÃjQuery µÄAjax¼ÓÔØÊý¾ÝÊÇ Èç¹ûʹÓÃget·½Ê½´«µÝ²ÎÊýÔò´æÔÚÒ»ÏÂÎÊÌâ
firefoxÏ´«µÝÊý¾ÝÕý³£
ieÏÂÔò»á³öÏÖ»º´æÎÊÌâ
½â¾ö·½·¨£º
1¡¢http://yourwebsite?parseInt(Math.random() * 1000) ÔÚurlºóÃæ¼ÓÉÏÒ»¸öËæ¼´Êý£¬ÕâÑùÿ´Î·¢Ë͵ľͲ»Ò»ÑùÁË£¬¶øÇÒ²»Ó°ÏìÄãµÄ¹¦ÄÜ.
2¡¢Ê¹ÓÃpost´«µÝ²ÎÊý
......
ÔÚC#ÖÐ
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;
using System.Collections;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.Ba ......
Ajax
Ö÷
Òª×é³É²¿·Ö
Ajax
ÊÇ
Asynchronous JavaScript and XML
£¨ÒÔ
¼°
DHTML
µÈ£©µÄËõд¡£
Ajax
ÓÉ
HTML
¡¢
JavaScript™
¼¼Êõ¡¢
DHTML
ºÍ
DOM
×é³É£¬ÕâÒ»½Ü³öµÄ·½·¨¿ÉÒÔ½«±¿×¾µÄ
Web
½çÃæת»¯³É½»»¥ÐÔµÄ
Ajax
Ó¦ÓóÌÐò¡£
AjaxµÄºËÐÄÊÇJavaScript¶ÔÏó XmlHttpRequest¡£¸Ã¶ÔÏóÔ ......
/*ÔÚÓÐÖÐÎIJÎÊýʱ,½ÓÊÕ·½ÐèҪʹÓÃUTF-8·½Ê½¶ÔÊý¾Ý½øÐнâÂë
*²»Ö§³Öpost¸½¼þ
*/
function getXmlHttpRequest() {
var xmlHttpRequest = null;
try {
xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
} ......
http://hi.baidu.com/cxzhang/blog/item/0166563892cc65fbb211c7b0.html.
http://topic.csdn.net/t/20030527/22/1842509.html
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Reflection;
public class ToJson
{
/// <summary>
......