Project Outline
«
pulp javascript framework

Class pulp.ajax

Defined in: pulp.ajax.js.

Constructor
^ top
new pulp.ajax(url, data, options)
Create a pulp.ajax object to send a GET or POST request to the server see pulp.ajax#setProperties for argument description

                  
                  
                  
                    
                      
Parameters:
url
data
options
Field Summary
^ top
defaultOptions The default options for pulp.ajax requests; see pulp.ajax#setProperties for description
transport Wrapper for XMLHttpRequest, normalizing behavior for all browsers and handling non-HTTP requests Separate from pulp.ajax to allow reusing XMLHttpRequest objects while allowing scripts to cache this object with all the core properties of the original XMLHttpRequest
json Class that automatically evaluates response as JSON and stores the result as responseObject
xml Class that automatically evaluates response as XML and stores an XML Document Object in responseXML
form Class that sends form data from options.form (defaults to document.forms[0]) options.form can be a form object, HTML id attribute, or form name/number
updater Class that sets the innerHTML of the given node to the responseText
Method Summary
^ top
reset() (chainable) Clear url, data, and options
setProperties([url] [, data] [, options]) (chainable) Set new values for url, data, and options
setUrl(url) (chainable) Set the url to which the ajax request will be made
setData(data) (chainable) Set the data parameters to send
extendData(data) (chainable) Add aditional data to the data parameters to send
setOptions(options) (chainable) Set options of the ajax object see pulp.ajax#setProperties
send(url, data, options) (chainable) Send a GET or POST request to the server see pulp.ajax#setProperties for argument description
abort() (chainable) Abort the Ajax Request (can be called directly or called after this.options.timeout seconds)
_timeout() Called on timeout; fires the timeout event and aborts
post(url, data, options) (chainable) Send a POST request to the server see pulp.ajax#setProperties for argument description
get(url, data, options) (chainable) Send a GET request to the server for argument description see pulp.ajax#setProperties for argument description
_respond() Respond to a ready state change, fire events for each state Fired on the transports onreadystatechange event
queryToObject(string [, delimiter="="], glue) Convert a query string to an object with name-value pairs
objectToQuery(object [, delimiter="="], glue) Convert an object with name-value pairs to a query string
request([options={}]) Convenience method to create an ajax object and send request
Field Detail
^ top
pulp.ajax.defaultOptions
The default options for pulp.ajax requests; see pulp.ajax#setProperties for description

									
								
									
										
										
										
										
				
								
pulp.ajax.transport
Wrapper for XMLHttpRequest, normalizing behavior for all browsers and handling non-HTTP requests Separate from pulp.ajax to allow reusing XMLHttpRequest objects while allowing scripts to cache this object with all the core properties of the original XMLHttpRequest

									
								
									
										
										
										
										
				
								
pulp.ajax.json
Class that automatically evaluates response as JSON and stores the result as responseObject

									
								
									
										
										
										
										
				
								
pulp.ajax.xml
Class that automatically evaluates response as XML and stores an XML Document Object in responseXML

									
								
									
										
										
										
										
				
								
pulp.ajax.form
Class that sends form data from options.form (defaults to document.forms[0]) options.form can be a form object, HTML id attribute, or form name/number

									
								
									
										
										
										
										
				
								
pulp.ajax.updater
Class that sets the innerHTML of the given node to the responseText

									
								
									
										
										
										
										
				
								
Method Detail
^ top
reset() -> pulp.ajax
Clear url, data, and options

										
									
Returns:
{pulp.ajax}
setProperties([url] [, data] [, options]) -> pulp.ajax
Set new values for url, data, and options

										
									
Parameters:
{String} url?, Default: The url to which to make the request
{String|Object} data?, Default: The key-value pairs to send to the server; in POST/GET requests, string should be in format key1=value&key2=value&arr[]=value&assoc[key]=value and Object should be an object: {key1: 'value', key2: 'value', arr: ['value'], assoc: {key: 'value'}}
{Object} options?, Default: Object containing ajax options @see pulp.ajax.defaultOptions
options.method: post or get
options.async: if false, all code execution will stop until the request returns or aborts
options.contentType: the mime type of data being sent
options.encoding: the encoding of the string sent to the server
options.parameters: the query string or object with name-value pairs representing the data to send
options.timeout: the number of seconds after which to automatically abort the request
options.requestHeaders: the http headers to send to the server
Returns:
{pulp.ajax}
setUrl(url) -> this
Set the url to which the ajax request will be made

										
									
Parameters:
{String} url
Returns:
{this}
setData(data) -> this
Set the data parameters to send

										
									
Parameters:
{Object|String} data Object with param-value pairs or http get string
Returns:
{this}
extendData(data) -> this
Add aditional data to the data parameters to send

										
									
Parameters:
{Object|String} data Object with param-value pairs or http get string
Returns:
{this}
setOptions(options) -> this
Set options of the ajax object see pulp.ajax#setProperties

										
									
Parameters:
{Object} options Object with key-value pairs of options
Returns:
{this}
send(url, data, options) -> this
Send a GET or POST request to the server see pulp.ajax#setProperties for argument description

										
									
Parameters:
url
data
options
Returns:
{this}
abort() -> pulp.ajax
Abort the Ajax Request (can be called directly or called after this.options.timeout seconds)

										
									
Returns:
{pulp.ajax}
_timeout() -> Undefiend
Called on timeout; fires the timeout event and aborts

										
									
Returns:
{Undefiend}
post(url, data, options) -> this
Send a POST request to the server see pulp.ajax#setProperties for argument description

										
									
Parameters:
url
data
options
Returns:
{this}
get(url, data, options) -> this
Send a GET request to the server for argument description see pulp.ajax#setProperties for argument description

										
									
Parameters:
url
data
options
Returns:
{this}
_respond() -> Undefined
Respond to a ready state change, fire events for each state Fired on the transports onreadystatechange event

										
									
Returns:
{Undefined}
pulp.ajax.queryToObject(string [, delimiter="="], glue) -> Object
Convert a query string to an object with name-value pairs

										
									
Parameters:
{String} string The query string
{String} delimiter?, Default: "=" The character separating name and value
glue
Returns:
{Object}
pulp.ajax.objectToQuery(object [, delimiter="="], glue) -> String
Convert an object with name-value pairs to a query string

										
									
Parameters:
{Object} object The object containing name-value pairs
{String} delimiter?, Default: "=" The character separating name and value
glue
Returns:
{String}
pulp.ajax.request([options={}]) -> pulp.ajax
Convenience method to create an ajax object and send request

										
									
Parameters:
{Object} options?, Default: {} Configure the ajax request
{String} options.type?, Default: The flavor of ajax request (json, xml, form, updater); defaults to a regular pulp.ajax object
{String} options.url?, Default: '' The url to which to send the ajax request
{String} options.params?, Default: {} Key-value pairs to send with request see pulp.ajax#setProperties for other option names, values and descriptions
Returns:
{pulp.ajax} Or child class depending on options.type (pulp.ajax.json, pulp.ajax.xml, pulp.ajax.form, pulp.ajax.updater)
Documentation generated by JsDoc Toolkit 2.1.0 on Tue Aug 18 2009 22:40:24; Template based on jProton by Pedro Simonetti