Returns the reference to a user-defined callback function that the JSDOSession or Session object executes to modify a request object before sending the request object to the server.
For example, this function might add a message header by modifying the XMLHttpRequest object used to send the request.
You do not typically use this property, because OpenEdge Mobile properly handles preparation of the request object for normal circumstances.
By default, the value of the onOpenRequest property is null, meaning that the request object is sent without modification. If the value is set to a callback function, the function takes a single object parameter.
Syntax
This is the syntax for setting this property to a function reference:
mySession.onOpenRequest = funcRef
mySession
A reference to the JSDOSession or Session object for which the request object is to be modified before sending a request to the server.
funcRef
A reference to a JavaScript callback function that has the following signature:
Syntax:
function [func-name] ( param )
func-name
The optional name of a function you have defined external to the property assignment. Alternatively, you can specify funcRef as the entire inline function definition without func-name.
param
An Object that has the following properties:
xhr — An object reference to the XMLHttpRequest object (XHR) used to send the request. The current request object can be modified by the function. When the callback is called, XMLHttpRequest.open( ) will already have been called on the XHR , but the callback can call open( ) again, overriding the effects of the first open( ) call. When the callback function is used for a login( ), addCatalog( ), or logout( ) call, although it should not be necessary and is not recommended, it is possible to replace the XHR entirely by creating a new object and assigning it as the value of the xhr property.
verb — The HTTP operation (GET, PUT, etc.) to be performed by the request.
uri — The URI to which the request is addressed.
session — A reference to the Session object that invoked the callback.
formPreTest — A Boolean specifying whether the current login( ) request is a preliminary request, used in cases of Form authentication, to determine whether the user is already logged in (true) or an actual login request (false).
async — A Boolean specifying whether the request is asynchronous (true) or synchronous (false).
For a JSDOSession object, if the callback function is used for a login( ), addCatalog( ), or logout( ) call, and if it calls XMLHttpRequest.open( ), the async property value passed to that open( ) call must be true (i.e., the open( ) method must specify that the request is to be sent asynchronously).
For a Session object, if the callback function is used for a login( ), addCatalog( ), or logout( ) call, and if it calls XMLHttpRequest.open( ), the async property value passed to that open( ) call must match the async value that was passed to the login( ), addCatalog( ), or logout( ) call.
If you assign a callback function as the value of onOpenRequest, it remains in effect for all requests for the duration of the session unless it is replaced by another function or is set to null.
Example
Be sure to reset the value of the property as necessary, as in the following example: