AjaxRequest > Object

Creates an object needed to send, receive and manage an asynchronous web request without using a page post back. The "Default" static fields are used to set all new AjaxRequest objects default values. So given the provided defaults, an Ajax request object will have no serialization on send, no parameters, a default wrapper property of "d" (of Serialization is JSON), a default time out of one minute, will prevent cache calls and will not send cookies.

Static Fields

AjaxRequest.DefaultDeserializationMethod SerializationMethod The deserialization type to use when receiving Ajax responses. Default is None.
AjaxRequest.DefaultParameters Dictionary Default parameters added to every Ajax Request.
AjaxRequest.DefaultResponseObjectProperty String The property to refer to to reach the "true" object. An example is ASP.NET sends back: "{ \"d\": {\"prop1\": value, \"prop2\": value } }". The true response object should have prop1 and prop2 as first level properties, but "d" is wrapping it. The static field will unwrap it for easier use by the script.
AjaxRequest.DefaultSerializationMethod SerializationMethod The serialization type to use when sending an Ajax request. Default is UrlEncoded.
AjaxRequest.DefaultTimeOut TimeSpan The amount of time to wait before aborting a request and throwing a timeout error. Default is 1 minute.
AjaxRequest.PreventCacheCalls Boolean Default is true. When true, a randomized query name/value is added to the url of the request to make the url unique.
AjaxRequest.SendCookies Boolean Determines if cookies are sent with the request. Default is false.

Constructors

AjaxRequest() Creates a blank Ajax request that has no url.
AjaxRequest(String url) Creates an Ajax request that will be sent to the provided url.

Fields

DeserializationMethod SerializationMethod The method used to deserialization the response.
Parameters Dictionary A set of name/value pairs sent to the server with the request. i.e.
url.com?name=value&name1=value2.
ResponseObjectProperty String The property to refer to to reach the "true" object. An example is ASP.NET sends back: "{ \"d\": {\"prop1\": value, \"prop2\": value } }". The true response object should have prop1 and prop2 as first level properties, but "d" is wrapping it. The static field will unwrap it for easier use by the script.
SerializationMethod SerializationMethod The serialization type to use when sending an Ajax request. Default is UrlEncoded.
Tag Object Any object to attach to the request.
TimeOut TimeSpan Amount of time to wait before aborting the request and calling OnTimeOut.
Type Type Returns Type.AjaxRequest
Url String The url to send the request to.
XMLHttpRequest HttpRequest Native JavaScript object used to make the request.

Events

OnAbort AjaxEventArgs Called when the request has been aborted.
OnError AjaxEventArgs Called if the request does not receive a 200 response.
OnSend AjaxEventArgs Called when the request is sent.
OnSuccess AjaxEventArgs Called when the request has received a response and deserialized (if applicable).
OnTimeOut AjaxEventArgs Called once the TimeOut time has passed and the request is aborted.

Functions

Abort() Aborts the request and fires the OnAbort event.
Post() Sends the request and uses the form on the page as the Parameters. This simulates a PostBack on ASP.NET.
Post(String id) Sends the request and uses the input fields found inside the provided id as Parameters.
Post(String id, PostOptions options) PostOptions Sends the request and uses the input fields found inside the provided id as Parameters. If id is null, uses the entire form. PostOptions is a flag enumeration that can be OR’d together (|).
Send() Sends the request.

Last edited Oct 24, 2011 at 8:55 PM by dahrkdaiz, version 8

Comments

No comments yet.