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

AJAX Cross Domain Same Origin Policy limitation

Õª×Ô£ºhttp://www.ibm.com/developerworks/library/wa-aj-jsonp1/
AJAX Same-Origin Policy(SOP) limitation:
 AJAX prevents cross-domail invokation, there are several ways to by pass this limitation.
1. write a proxy on the server side. The SOP limitation only exists only on the javascript side.  While on the side, we can still invoke the other domail url such as via HttpClient
2. iFrame ( not sure )
3. JSONP(JSON with Padding)
the same-origin policy doesn't prevent the insertion of dynamic script elements into the document. That is, you could dynamically insert JavaScript from different domains, carrying JSON data in them.
<mce:script type="text/javascript"><!--
// This is our function to be called with JSON data
function showPrice(data) {
alert("Symbol: " + data.symbol + ", Price: " + data.price);
}
var url = “ticker.js”; // URL of the external script
// this shows dynamic script insertion
var script = document.createElement('script');
script.setAttribute('src', url);
// load the script
document.getElementsByTagName('head')[0].appendChild(script);
// --></mce:script>
Note that, in order to do this, you must have a callback function already defined in the Web page at the time of insertion.
Beginning with version 1.2, jQuery has had native support for JSONP calls. You can load JSON data located on another domain if you specify a JSONP callback, which can be done using the following syntax: url?callback=?.
AJAX invoke:
jQuery.getJSON("http://www.yourdomain.com/jsonp/ticker?symbol=IBM&callback=?",
function(data) {
alert("Symbol: " + data.symbol + ", Price: " + data.price);
});

Another domain generates json data and returned to client side with callback function.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String jsonData = getDataAsJson(req.getParameter("symbol"));
String output = req.getParameter("


Ïà¹ØÎĵµ£º

Ajax ºÍ XML: ÎåÖÖ³£¼û Ajax ģʽ

ºÃ¾Ã²»ÅöWEBµÄ¶«¶«ÁË,×î½üѧϰ£Ó£Á£ÐµÄ£Â£Ó£Ð¼¼Êõ£¬ÓÖÓõ½ÕâЩ£¬Ë³±ãתƪÎÄÕ£¬±¸²é£®
Ô­ÎĵØÖ·: http://www.ibm.com/developerworks/cn/xml/x-ajaxxml2/
Ajax ºÍ XML:
Îå
ÖÖ³£¼û Ajax ģʽ
¿ÉÁ¢¼´Ê¹ÓÃÕâЩ·Ç³£ÓÐÓÃµÄ Ajax Éè¼Æģʽ
ÎĵµÑ¡Ïî
<tr valign="top"><td width="8">< ......

AJAXÖÐDragPanelExtenderÀ©Õ¹¿Ø¼þ


Ò³Ãæ´úÂ룺
<head runat="server">
    <title>ÎÞ±êÌâÒ³</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManage ......

asp.netÔÚÓÃajaxµÄʱºòÈçºÎµ¯³ö¶Ô»°¿ò


<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
    <asp:updatepanel ID="UP" runat="server">
      <ContentTemplate>
......

ajax¿çÓò·ÃÎÊ ·½·¨´óÈ«

Case I. Web´úÀíµÄ·½Ê½ (on Server A)
¼´Óû§·ÃÎÊAÍøվʱËù²úÉúµÄ¶ÔBÍøÕ¾µÄ¿çÓò·ÃÎÊÇëÇó¾ùÌá½»µ½AÍøÕ¾µÄÖ¸¶¨Ò³Ã棬ÓɸÃÒ³Ãæ´úÌæÓû§Ò³ÃæÍê³É½»»¥£¬´Ó¶ø·µ»ØºÏÊʵĽá¹û¡£´Ë·½°¸¿ÉÒÔ½â¾öÏֽ׶ÎËùÄܹ»Ïëµ½µÄ¶àÊý¿çÓò·ÃÎÊÎÊÌ⣬µ«ÒªÇóAÍøÕ¾ÌṩWeb´úÀíµÄÖ§³Ö£¬Òò´ËAÍøÕ¾ÓëBÍøÕ¾Ö®¼ä±ØÐëÊǽôÃÜЭ×÷µÄ£¬ÇÒÿ´Î½»»¥¹ý³Ì£¬AÍøÕ¾µÄ· ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ