PDA

View Full Version : How to implement an page which can provide for Ext.data.ScriptTagProxy's url?



jianwen_yu
10 May 2007, 11:49 PM
:">
this page should be with asp.net.

Animal
11 May 2007, 12:58 AM
Extract from the latest documentation comments in SVN which should help out a lot:



* An implementation of Ext.data.DataProxy that reads a data object from a URL which may be in a domain
* other than the originating domain of the running page.<br>
* <p>
* <em>Note that this class must be used to retrieve data from a domain other than the domain
* from which the running page was served.</em><br>
* <p>
* The content passed back from a server resource requested by a ScriptTagProxy is executable javascript
* source code that is used as the source inside a &lt;script> tag.<br>
* <p>
* In order for the browser to process the returned data, the server must wrap the data object
* with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
* Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
* depending on whether the callback name was passed:
* <p>
* <pre><code.
boolean scriptTag = false;
String cb = request.getParameter("callback");
if (cb != null) {
scriptTag = true;
response.setContentType("text/javascript");
} else {
response.setContentType("application/x-json");
}
Writer out = response.getWriter();
if (scriptTag) {
out.write(cb + "(");
}
out.print(dataBlock.toJsonString());
if (scriptTag) {
out.write(");");
}
</pre></code>

jianwen_yu
11 May 2007, 5:23 AM
Could tell me more detailed!
Thanks in advance!;)

Animal
11 May 2007, 7:50 AM
You send back a javascript statement which calls the function named in the "callback" parameter on the data you want to return.