易截截图软件、单文件、免安装、纯绿色、仅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 的状态介绍

在《Pragmatic Ajax A Web 2.0 Primer 》中偶然看到对readyStae状态的介绍,感觉这个介绍很实在,摘译如下:
0: (Uninitialized) the send( ) method has not yet been invoked.
1: (Loading) the send( ) method has been invoked, request in progress.
2: (Loaded) the send( ) method has completed, entire respons ......

asp.net在用ajax的时候如何弹出对话框


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

ASP.net+AJAX 弹出新窗口代码

ScriptManager.RegisterStartupScript(p1, this.GetType(), "click", "alert('ok')", true);//p1是updatepanel的id
ScriptManager.RegisterStartupScript(p1, this.GetType(), "click", "alert('ok')", true);//p1是updatepanel的id
......

struts2+jquery+ajax异步提交

struts2版本:struts-2.1.8.1
异常:java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/TextUtils
原因:jsonplugin-0.34.jar 配合 struts2-core-2.1.8.1.jar 使用的情况下报的异常,但以前的项目中jsonplugin-0.34.jar 配合 struts2-core-2.1.6.jar 使用不会出现这样的异常
解决方法:去掉jsonplugin-0.34 ......

ASP.NET 2.0 AJAX中Webservice调用方法

ASP.NET 2.0 Ajax中能够在客户端js中很方便地调用服务器Webservice,以下为一些调用的示例。笔者安装的ASP.NET 2.0 AJAX
版本为AJAX November CTP。
三个示例分别为:
1 带参数的WS方法
2 不带参数的WS方法
3 参数类型为DataTable的WS方法
一、WebMethod
注意要点:
1 WebMethod类需要添加命名空间 Microsoft.Web. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号