onOpenRequest property
- Last Updated: April 9, 2019
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Returns the reference to a user-defined callback function that the
JSDOSession 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 the JSDOSession object properly handles preparation of the request object for normal
circumstances.
Data type:
function
Access: Readable/Writable
Applies to: progress.data.JSDOSession class
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
- A reference to the
JSDOSessionobject 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
Objectthat 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 callopen( )again, overriding the effects of the firstopen( )call. When the callback function is used for aaddCatalog( )orlogout( )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 thexhrproperty.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 theSessionobject that invoked the callback.async— Abooleanspecifying whether the request is asynchronous (true) or synchronous (false).
CAUTION: For aJSDOSessionobject, if the callback function is used for aaddCatalog( )orlogout( )call, and if it callsXMLHttpRequest.open( ), theasyncproperty value passed to thatopen( )call must betrue(i.e., theopen( )method must specify that the request is to be sent asynchronously).
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 for the JSDOSession object,
myJSDOsession:
|