Class Ext.data.ScriptTagProxy
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.
Note that if you are retrieving data from a page that is in a domain that is NOT the same as the originating domain
of the running page, you must use this class, rather than DataProxy.
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 <script> tag.
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:
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(");");
}
Config Options
|
callbackParam : String
(Optional) The name of the parameter to pass to the server which tells the server the name of the callback function s...
(Optional) The name of the parameter to pass to the server which tells the server the name of the callback function set up by the load call to process the returned data object. Defaults to "callback". The server-side processing must read this parameter value, and generate javascript output which calls this named function passing the data object as its only parameter.
|
ScriptTagProxy |
|
nocache : Boolean
(Optional) Defaults to true. Disable cacheing by adding a unique parameter name to the request.
|
ScriptTagProxy |
|
timeout : Number
(Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
|
ScriptTagProxy |
|
url : String
The URL from which to request the data object.
|
ScriptTagProxy |
Public Properties
This class has no public properties.
Public Methods
|
ScriptTagProxy( Object config )
Parameters:
config : ObjectA configuration object.
Returns:
|
ScriptTagProxy |
|
abort() : void
Abort the current server request.
Abort the current server request.
|
ScriptTagProxy |
|
load( Object params , Ext.data.DataReader reader , Function callback , Object scope , Object arg ) : void
Load data from the configured URL, read the data object into
a block of Ext.data.Records using the passed Ext.data.Da...
Load data from the configured URL, read the data object into
a block of Ext.data.Records using the passed Ext.data.DataReader implementation, and
process that block using the passed callback.
Parameters:
params : ObjectAn object containing properties which are to be used as HTTP parameters
for the request to the remote server. reader : Ext.data.DataReaderThe Reader object which converts the data
object into a block of Ext.data.Records. callback : FunctionThe function into which to pass the block of Ext.data.Records.
The function must be passed
- The Record block object
- The "arg" argument from the load function
- A boolean success indicator
scope : ObjectThe scope in which to call the callback arg : ObjectAn optional argument which is passed to the callback as its second parameter.
Returns:
|
ScriptTagProxy |
Public Events
This class has no public events.