| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

XHRequest

Page history last edited by PBworks 17 years, 11 months ago


 

XHRequest

(extends Object)


Object Summary

 

A stub that is used to create a cross-browser AJAX interface.


Constructor

 

XHRequest()

Constructs a new XHRequest object.


Methods

 

XHRequest.removeAllFields()

 

comments

Removes all field-value pairs.


XHRequest.addField(strField,strValue)

 

parameters

strField - field.

strValue - corresponding value.

 

comments

Adds a new field-value pair to be posted.


XHRequest.post(strURL)

 

parameters

strURL - The URL to post the AJAX request.

 

comments

Asynchronously posts the AJAX request.


XHRequest.postSynchronized(strURL)

 

parameters

strURL - The URL to post the AJAX request.

 

comments

Synchronously posts the AJAX request. Script execution stops and continues after the server's response reaches client.

 

The difference between post and postSynchronized methods is that the latter waits for the request to complete and then program execution continues, while the former executes as a separate thread.

Note that, synchonized posts are generally not recommended because they may create a frozen GUI feeling on the client side.


XHRequest.get(strURL)

 

parameters

strURL - The URL to send the request. Note that usual cross-frame security issues apply to this url as well.

 

comments

Creates an asynchronous HTTP_GET request to strURL.


XHRequest.getSynchronized(strURL)

 

parameters

strURL - The URL to send the request. Note that usual cross-frame security issues apply to this url as well.

 

comments

Creates an synchronized HTTP_GET request to strURL.

 

The difference between get and getSynchronized methods is that the latter waits for the request to complete and then program execution continues, while the former executes as a separate thread.

Note that, synchonized posts are generally not recommended because they may create a frozen GUI feeling on the client side.


XHRequest.getObject()

 

returns

The internally stored XMLHttpRequest object.

 

comments

Returns the internally stored XMLHttpRequest object. If there is no stored XHR object creates one and returns it. Otherwise returns the existing XHR object.


XHRequest.finalize()

 

comments

Cleans up memory and deallocates all consumed resources.

 

This method is implicitly called when either abort method is called or AJAX response completes normally (which automagically triggers oncomplete).


XHRequest.init()

 

comments

Initializes the object.

 

This method is implicity called by the constructor, thus you don't need to call it at construction phase.

 

However, if you want to post another AJAX request after one has completed, you need to re-initialize the object with init method.


XHRequest.abort()

 

comments

Aborts the current request and releases the resources used.


XHRequest.oncomplete(strResponseText,strResponseXML)

 

parameters

strResponseText - The response text.

strResponseXML - The response XML.

 

comments

This method MUST be overridden.

 

The method is called by the object whenever the request completes.

 

See the test case for an example usage.


XHRequest.onerror(intStatus,strStatusText)

 

parameters

intStatus - The status code.

strStatusText - The error message.

 

comments

This method MUST be overridden.

 

The method is called by the object whenever an error occurs and the request does not complete successfully.

 

An error is raised if the HTTP_STATUS_CODE is not 400 (completed) or 304 (retrieved from cache).


See Also

 

None given.


Usage Examples

 

Comments (0)

You don't have permission to comment on this page.