IO
Provides utility that brokers HTTP requests through a simplified interface
defined in: base.js
Function Namespace
- IO (c)
Attributes
- IO. isLocal {Boolean} <static> whether current application is a local application (protocal is file://,widget://,about://)
Methods
- IO. get (url, data, callback, dataType) <static> perform a get request
- IO. getConfig () <static> get default config value for io request
- IO. getJSON (url, data, callback) <static> perform a get request to fetch json data from server
- IO. jsonp (url, data, callback) <static> preform a jsonp request
- IO. post (url, data, callback, dataType) <static> preform a post request
- IO. serialize (formElement) <static> form serialization
- IO. setupConfig (setting) <static> name-value object that set default config value for io request
- IO. upload (url, form, data, callback, dataType) <static> submit form without page refresh
Events
Function Namespace Detail
-
IO (c)Provides utility that brokers HTTP requests through a simplified interface
- Parameters
-
-
c
{Object}
name-value of object to config this io request.
all values are optional.
default value can be set through io.setupConfig
-
c.url
{String}
request destination -
c.type
{String}
request type. eg: "get","post"
Default: "get"
-
c.contentType
{String}
Default: "application/x-www-form-urlencoded; charset=UTF-8"
Data will always be transmitted to the server using UTF-8 charset
-
c.accepts
{Object}
Default: depends on DataType.
The content type sent in request header that tells the server
what kind of response it will accept in return.
It is recommended to do so once in the io.setupConfig -
c.async
{Boolean}
Default: true
whether request is sent asynchronously
-
c.cache
{Boolean}
Default: true ,false for dataType "script" and "jsonp"
if set false,will append _ksTs=Date.now() to url automatically
-
c.contents
{Object}
a name-regexp map to determine request data's dataType
It is recommended to do so once in the io.setupConfig
-
c.context
{Object}
specify the context of this request's callback (success,error,complete) -
c.converters
{Object}
Default:{text:{json:JSON.parse,html:mirror,text:mirror,xml:KISSY.parseXML}}
specified how to transform one dataType to another dataType
It is recommended to do so once in the io.setupConfig -
c.crossDomain
{Boolean}
Default: false for same-domain request,true for cross-domain request
if server-side jsonp redirect to another domain ,you should set this to true -
c.data
{Object}
Data sent to server.if processData is true,data will be serialized to String type.
if value if an Array, serialization will be based on serializeArray. -
c.dataType
{String}
return data as a specified type
Default: Based on server contentType header
"xml" : a XML document
"text"/"html": raw server data
"script": evaluate the return data as script
"json": parse the return data as json and return the result as final data
"jsonp": load json data via jsonp -
c.headers
{Object}
additional name-value header to send along with this request. -
c.jsonp
{String}
Default: "callback"
Override the callback function name in a jsonp request. eg:
set "callback2" , then jsonp url will append "callback2=?". -
c.jsonpCallback
{String}
Specify the callback function name for a jsonp request.
set this value will replace the auto generated function name.
eg:
set "customCall" , then jsonp url will append "callback=customCall" -
c.mimeType
{String}
override xhr's mime type -
c.processData
{Boolean}
Default: true
whether data will be serialized as String -
c.scriptCharset
{String}
only for dataType "jsonp" and "script" and "get" type.
force the script to certain charset. -
c.beforeSend
{Function}
beforeSend(xhrObject,config)
callback function called before the request is sent.this function has 2 arguments
1. current KISSY xhrObject
2. current io config
note: can be used for add progress event listener for native xhr's upload attribute see XMLHttpRequest2 -
c.success
{Function}
success(data,textStatus,xhr)
callback function called if the request succeeds.this function has 3 arguments
1. data returned from this request with type specified by dataType
2. status of this request with type String
3. XhrObject of this request , for details IO.XhrObject -
c.error
{Function}
success(data,textStatus,xhr)
callback function called if the request occurs error.this function has 3 arguments
1. null value
2. status of this request with type String,such as "timeout","Not Found","parsererror:..."
3. XhrObject of this request , for details IO.XhrObject -
c.complete
{Function}
success(data,textStatus,xhr)
callback function called if the request finished(success or error).this function has 3 arguments
1. null value if error occurs or data returned from server
2. status of this request with type String,such as success:"ok", error:"timeout","Not Found","parsererror:..."
3. XhrObject of this request , for details IO.XhrObject -
c.timeout
{Number}
Set a timeout(in seconds) for this request.if will call error when timeout -
c.serializeArray
{Boolean}
whether add [] to data's name when data's value is array in serialization -
c.xhrFields
{Object}
name-value to set to native xhr.set as xhrFields:{withCredentials:true} -
c.username
{String}
a username tobe used in response to HTTP access authentication request -
c.password
{String}
a password tobe used in response to HTTP access authentication request -
c.xdr
{Object}
cross domain request config object -
c.xdr.src
{String}
Default: kissy's flash url flash sender url -
c.xdr.use
{String}
if set to "use", it will always use flash for cross domain request even in chrome/firefox -
c.xdr.subDomain
{Object}
cross sub domain request config object -
c.xdr.subDomain.proxy
{String}
proxy page,eg:
a.t.cn/a.htm send request to b.t.cn/b.htm:
1. a.htm set document.domain='t.cn'
2. b.t.cn/proxy.htm 's content is <script>document.domain='t.cn'</script>
3. in a.htm , call io({xdr:{subDomain:{proxy:'/proxy.htm'}}})
-
c
{Object}
- Returns
-
- {IO.XhrObject} current request object
Attributes Detail
Methods Detail
-
perform a get request
Defined in:ajax.js.- Parameters
-
- url {String} request destination
- [ data ] {Object} name-value object associated with this request
-
callback
{Function()}
success callback when this request is done with parameter
1. data returned from this request with type specified by dataType
2. status of this request with type String
3. XhrObject of this request , for details IO.XhrObject - [ dataType ] {String} the type of data returns from this request ("xml" or "json" or "text")
- Returns
-
get default config value for io request
- Returns
-
- {Object}
-
perform a get request to fetch json data from server
Defined in:ajax.js.- Parameters
-
- url {String} request destination
- [ data ] {Object} name-value object associated with this request
-
callback
{Function()}
success callback when this request is done
with parameter
1. data returned from this request with type JSON
2. status of this request with type String
3. XhrObject of this request , for details IO.XhrObject
- Returns
-
preform a jsonp request
Defined in:ajax.js.- Parameters
-
- url {String} request destination
- [ data ] {Object} name-value object associated with this request
-
callback
{Function()}
success callback when this request is done
with parameter
1. data returned from this request with type specified by dataType
2. status of this request with type String
3. XhrObject of this request , for details IO.XhrObject
- Returns
-
preform a post request
Defined in:ajax.js.- Parameters
-
- url {String} request destination
- [ data ] {Object} name-value object associated with this request
-
callback
{Function()}
success callback when this request is done
with parameter
1. data returned from this request with type specified by dataType
2. status of this request with type String
3. XhrObject of this request , for details IO.XhrObject - [ dataType ] {String} the type of data returns from this request ("xml" or "json" or "text")
- Returns
-
form serialization
Defined in:ajax.js.- Parameters
-
- formElement {HTMLElement[]|HTMLElement|NodeList} form elements
- Returns
-
- {String} serialized string represent form elements
-
name-value object that set default config value for io request
- Parameters
-
- setting {Object} for details see io
-
submit form without page refresh
Defined in:ajax.js.- Parameters
-
- url {String} request destination
- form {HTMLElement|NodeList} element tobe submited
- [ data ] {Object} name-value object associated with this request
-
callback
{Function()}
success callback when this request is done
with parameter
1. data returned from this request with type specified by dataType
2. status of this request with type String
3. XhrObject of this request , for details IO.XhrObject - [ dataType ] {String} the type of data returns from this request ("xml" or "json" or "text")
- Returns
Events Detail
-
complete (e) view sourcefired after request completes (success or error)
- Parameters
-
- e {Event.Object}
- e.ajaxConfig {Object} current request 's config
- e.xhr {IO.XhrObject} current xhr object
-
error (e) view sourcefired after request occurs error
- Parameters
-
- e {Event.Object}
- e.ajaxConfig {Object} current request 's config
- e.xhr {IO.XhrObject} current xhr object
-
send (e) view sourcefired before sending request
- Parameters
-
- e {Event.Object}
- e.ajaxConfig {Object} current request 's config
- e.xhr {IO.XhrObject} current xhr object
-
start (e) view sourcefired before generating request object
- Parameters
-
- e {Event.Object}
- e.ajaxConfig {Object} current request 's config
- e.xhr {IO.XhrObject} current xhr object
-
success (e) view sourcefired after request succeeds
- Parameters
-
- e {Event.Object}
- e.ajaxConfig {Object} current request 's config
- e.xhr {IO.XhrObject} current xhr object
Classes
- Anim
- Anim.Easing
- Attribute
- Base
- Button
- ComboBox
- ComboBox.LocalDataSource
- ComboBox.RemoteDataSource
- Component
- Component.Container
- Component.Controller
- Component.Manager
- Component.Render
- Component.UIBase
- Component.UIBase.Align
- Component.UIBase.Box
- Component.UIBase.Close
- Component.UIBase.Constrain
- Component.UIBase.ContentBox
- Component.UIBase.Drag
- Component.UIBase.Loading
- Component.UIBase.Mask
- Component.UIBase.Position
- Component.UIBase.Resize
- Component.UIBase.StdMod
- Cookie
- DataLazyload
- DD
- DD.Constrain
- DD.DDM
- DD.Draggable
- DD.DraggableDelegate
- DD.Droppable
- DD.DroppableDelegate
- DD.Proxy
- DD.Scroll
- DOM
- Editor
- Editor.Range
- Editor.Utils
- Editor.Walker
- Event
- Event.Object
- Event.Target
- IO
- IO.XhrObject
- KISSY
- KISSY.Defer
- KISSY.Loader
- KISSY.Loader.Module
- KISSY.Loader.Package
- KISSY.Promise
- Menu
- Menu.FilterMenu
- Menu.Item
- Menu.PopupMenu
- Menu.Separator
- MenuButton
- MenuButton.Option
- MenuButton.Select
- MVC
- MVC.Collection
- MVC.Model
- MVC.Router
- MVC.View
- NodeList
- Overlay
- Overlay.Dialog
- Overlay.Popup
- Resizable
- Tree
- Tree.CheckNode
- Tree.CheckTree
- Tree.Node
- Waterfall
- Waterfall.Loader