Package: | Ext.data |
Class: | Connection |
Extends: | Observable |
Subclasses: | Ajax |
Defined In: | Connection.js |
Requests made by this class are asynchronous, and will return immediately. No data from the server will be available to the statement immediately following the request call. To process returned data, use a callback in the request options object, or an event listener.
Note: If you are doing a file upload, you will not get a normal response object sent back to your callback or event handler. Since the upload is handled via in IFRAME, there is no XMLHttpRequest. The response object is created using the innerHTML of the IFRAME's document as the responseText property and, if present, the IFRAME's XML document as the responseXML property.
Method | Defined By | |
---|---|---|
Connection( Object config ) |
Connection | |
abort( [Number transactionId ] ) : void |
Connection | |
Aborts any outstanding request. | ||
addEvents( Object object ) : void |
Observable | |
Used to define events on this Observable | ||
addListener( String eventName , Function handler , [Object scope ], [Object options ] ) : void |
Observable | |
Appends an event handler to this component | ||
fireEvent( String eventName , Object... args ) : Boolean |
Observable | |
Fires the specified event with the passed parameters (minus the event name). | ||
hasListener( String eventName ) : Boolean |
Observable | |
Checks to see if this object has any listeners for a specified event | ||
isLoading( [Number transactionId ] ) : Boolean |
Connection | |
Determine whether this object has a request outstanding. | ||
on( String eventName , Function handler , [Object scope ], [Object options ] ) : void |
Observable | |
Appends an event handler to this element (shorthand for addListener) | ||
purgeListeners() : void | Observable | |
Removes all listeners for this object | ||
removeListener( String eventName , Function handler , [Object scope ] ) : void |
Observable | |
Removes a listener | ||
request( [Object options ] ) : Number |
Connection | |
Sends an HTTP request to a remote server. | ||
un( String eventName , Function handler , [Object scope ] ) : void |
Observable | |
Removes a listener (shorthand for removeListener) |
Event | Defined By | |
---|---|---|
beforerequest : ( Connection conn , Object options ) |
Connection | |
Fires before a network request is made to retrieve a data object. | ||
requestcomplete : ( Connection conn , Object response , Object options ) |
Connection | |
Fires if the request was successfully completed. | ||
requestexception : ( Connection conn , Object response , Object options ) |
Connection | |
Fires if an error HTTP status was returned from the server. See {@link http://www.w3.org/Protocols/rfc2616/rfc2616-se... |
Config Options | Defined By | |
---|---|---|
autoAbort : Boolean | Connection | |
(Optional) Whether this request should abort any pending requests. (defaults to false) | ||
defaultHeaders : Object | Connection | |
(Optional) An object containing request headers which are added to each request made by this object. (defaults to und... | ||
disableCaching : Boolean | Connection | |
(Optional) True to add a unique cache-buster param to GET requests. (defaults to true) | ||
extraParams : Object | Connection | |
(Optional) An object containing properties which are used as extra parameters to each request made by this object. (d... | ||
method : String | Connection | |
(Optional) The default HTTP method to be used for requests. (defaults to undefined; if not set but parms are present ... | ||
timeout : Number | Connection | |
(Optional) The timeout in milliseconds to be used for requests. (defaults to 30000) | ||
url : String | Connection | |
(Optional) The default URL to be used for requests to the server. (defaults to undefined) |
public function Connection( Object config
)
config
: Objectpublic function abort( [Number transactionId
] )
transactionId
: Numbervoid
public function addEvents( Object object
)
object
: Objectvoid
public function addListener( String eventName
, Function handler
, [Object scope
], [Object options
] )
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Object
Combining Options
Using the options argument, it is possible to combine different types of listeners:
A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)
el.on('click', this.onClick, this, {
single: true,
delay: 100,
forumId: 4
});
Attaching multiple handlers in 1 call
The method also allows for a single argument to be passed which is a config object containing properties
which specify multiple handlers.
el.on({
'click': {
fn: this.onClick,
scope: this,
delay: 100
},
'mouseover': {
fn: this.onMouseOver,
scope: this
},
'mouseout': {
fn: this.onMouseOut,
scope: this
}
});
Or a shorthand syntax which passes the same scope object to all handlers:
el.on({
'click': this.onClick,
'mouseover': this.onMouseOver,
'mouseout': this.onMouseOut,
scope: this
});
void
public function fireEvent( String eventName
, Object... args
)
eventName
: Stringargs
: Object...Boolean
public function hasListener( String eventName
)
eventName
: StringBoolean
public function isLoading( [Number transactionId
] )
transactionId
: NumberBoolean
public function on( String eventName
, Function handler
, [Object scope
], [Object options
] )
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Objectvoid
public function purgeListeners()
void
public function removeListener( String eventName
, Function handler
, [Object scope
] )
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function request( [Object options
] )
options
: ObjectNumber
public function un( String eventName
, Function handler
, [Object scope
] )
eventName
: Stringhandler
: Functionscope
: Objectvoid
public event beforerequest
conn
: Connectionoptions
: Objectpublic event requestcomplete
conn
: Connectionresponse
: Objectoptions
: Objectpublic event requestexception
conn
: Connectionresponse
: Objectoptions
: ObjectautoAbort : Boolean
defaultHeaders : Object
disableCaching : Boolean
extraParams : Object
method : String
timeout : Number
url : String