1. Introduction
The Uize.Comm.Script class implements support for communication with a server via cross-site scripting through the insertion of script tags into the document.
DEVELOPERS: Tim Carter
The Uize.Comm.Script module defines the Uize.Comm.Script class, a subclass of the Uize.Comm abstract class. In order to implement support for communication through script tags, this class overrides the implementation of the performRequest instance method inherited from the Uize.Comm base class. There are no additional methods provided by this class - all the interface is provided in the Uize.Comm superclass.
2. Set-get Properties
2.1. callbackMode
A string, indicating whether the callback function should be handled by the server or client.
While traditional xss techniques pass the name of the callback to the server so that it can be included in the response, certain situations may arise where the server is not capable of handling the callback. For example, this may occur when some client code wishes to query a service that is built by a third-party, and thus not under the control of the client developer. In the preceding example, the developer can set the value of callbackMode to 'client' so that Uize.Comm.Script handles the callback itself.
Uize.Comm.Script does this by inserting two script nodes into the DOM each time a request is made. The first request queries the server. The second calls the callback. This implementation assumes that the script tags are written synchronously, ie., the first finishes before the second is written out; this is the case for most modern browsers. As a result, the callback only gets executed once all the data from the server is in memory.
This does place some restrictions on the callback function. Unlike most callbacks in the Uize.Comm class and subclasses, the callback in 'client' mode does not receive any parameters. Once the 'client' callback is called, the only certainty that exists with regard to the server request is that it completed. It is the responsibility of the callback developer to know the nature of that data.
2.1.1. Values
The possible values for the callbackMode set-get property are 'client' or 'server'. 'server' mode means that the callback function will be passed to the server and it is the server's responsibility to call it upon completion of the task. If 'client' mode is set, Uize.Comm.Script will call the callback function after each request is made.
NOTES
the initial value is 'server' |