timeoutSeconds: 3000, //3 秒后超时,如果为 0 则永不超时 method: \
content: {a: 1, b: 2}, //要提交的数据
load: function(type, data, evt) { alert(data); }, //type should be \error: function(type, error) { alert(error.message); }, //error is dojo.io.Error timeout: function(type) { alert(\请求超时!\});
dojo.io.queueBind
有时,我们需要一次发出多个网页请求,则应该使用 dojo.io.queueBind,因为浏览器可能 只允许同时发出有限个数的请求,如果是使用 dojo.io.bind 的话,则有可能会申请不到新的 XMLHttp 对象而导致出错。
用法与 dojo.io.bind 是一样的。 dojo.io.argsFromMap
用来把对象转换为 URL 的参数形式 Usage Example:
dojo.io.argsFromMap({a:1,b:2,c:3}); //will return \ dojo.io.argsFromMap({name:\名称\值
\\荤X?&name=????§°&\ utf 格式,否则 dojo.string.encodeAscii 返回的编码是很怪异的
dojo.io.argsFromMap({a:1,b:2,c:3}, \,最后一个参 数可以控制指定名称的值出现在最后 dojo.io.setIFrameSrc 设置 IFrame 的 Src Usage Example:
dojo.io.setIFrameSrc(dojo.byId(\打 开指定的网页
dojo.io.setIFrameSrc(dojo.byId(\me 打开指定的网页,并覆盖浏览器的历史记录 模块:dojo.io.BrowserIO
基本上就提供了 dojo.io.XMLHTTPTransport 这个对象
XMLHTTPTransport 一般能够满足我们的需求,但是其有几个限制:它不能传输文件,不能够成功执行 跨域名的远程请求,并且不支持 file:// 这样的协议 因此,根据应用要求,我们可能会需要选用其它的
transport: dojo.io.IframeTransport, dojo.io.repubsubTranport, dojo.io.s criptSrcTransport, ShortBusTransport
dojo.io.IframeTransport,用法与 xmlhttp 是一样的,其优点就是可以跨域,不存在任何的安全问题 如果 Request 指定的 mimetype 是 text 或 javas cript,返回的内容应该是放在第一个 textarea 里的 内容,如果指定的 mimetype 是 html,则 IFrame 里的 html 则是需要的内容。因为浏览器兼容的原因, IframeTransport 不能正确处理返回类型为 XML 的请求。
关于 Rpc,这个类似于 Remoting 的东西,也将在以后对其进行介绍。 模块:dojo.string.extras 模块:dojo.string.common 模块:dojo.string
dojo.string.common 和 dojo.string 是一样的,只要 require 其中一个就可以使用以下方法 dojo.string.capitalize 把每一个单词的首字母大写 Usage Example:
dojo.string.capitalize(\dojo.string.isBlank
判断输入字符串是否为空或全是空白字符,如果传入对象为非字符串则也会返回 true Usage Example:
dojo.string.isBlank(\dojo.string.escape
参数 1 为 type,可传值为: xml/html/xhtml, sql, regexp/regex, javas cript/js cript/js, ascii 将按照所传 type 对字符串进行编码 Usage Example:
dojo.string.escape(\type='text' value='' />\dojo.string.encodeAscii
dojo.string.escapeXml dojo.string.escapeSql dojo.string.escapeRegExp
dojo.string.escapeJavas cript dojo.string.escapeString
这些函数也就是 dojo.string.escape 所调用的,这里无需多说 dojo.string.summary
取得输入字符串的缩略版本 Usage Example:
dojo.string.summary(\dojo.string.endsWith
判断输入字符串是否以指定的字符串结尾 Usage Example:
dojo.string.endsWith(\
dojo.string.endsWith(\dojo.string.endsWithAny
判断输入字符串是否以指定的任意字符串结尾 Usage Example:
dojo.string.endsWithAny(\dojo.string.startsWith
判断输入字符串是否以指定的字符串开头 Usage Example:
dojo.string.startsWith(\
dojo.string.startsWith(\dojo.string.startsWithAny
判断输入字符串是否以指定的任意字符串开头 Usage Example:
dojo.string.startsWithAny(\dojo.string.has
判断输入字符串是否含有任意指定的字符串 Usage Example:
dojo.string.has(\dojo.string.normalizeNewlines 按要求转换回车换行的格式 Usage Example:
dojo.string.normalizeNewlines(\dojo.string.splitEscaped 将字符串按分隔符转换为数组 Usage Example:
dojo.string.splitEscaped(\dojo.string.trim 去掉字符串的空白
dojo.require(\defined in dojo/string.js
This version of trim() was taken from Steven Levithan’s blog. The short yet performant version of this function is dojo.trim(), which is part of Dojo base. Usage
var foo=dojo.string.trim(str: String); (view source) str
parameter type String
description
Usage Example: s = \
dojo.string.trim(s); //will return \dojo.string.trim(s, 0);//will return \dojo.string.trim(s, 1);//will return \
dojo.string.trim(s, -1);//will return \dojo.string.trimStart 去掉字符串开头的空白 Usage Example:
s = \dojo.string.trimEnd 去掉字符串结尾的空白 Usage Example:
s = \dojo.string.repeat
生成由同一字符(串)重复组成的字符串 Usage Example:
dojo.string.repeat(\
dojo.string.repeat(\dojo.string.pad 使用字符补齐字符串
dojo.require(\defined in dojo/string.js
Pad a string to guarantee 保证 that it is at least 最小的 size length by filling 装填character ch at either the start or end of the string. Pads at the start, by default. Usage
var foo=dojo.string.pad(text: String, size: Integer, ch: String?, end: Boolean?); parameter type description text size ch end
String the string to pad
Integer length to provide padding
String Optional. character to pad, defaults to ‘0’
Boolean Optional. adds padding at the end if true, otherwise pads at start Usage Example:
dojo.string.pad(\
dojo.string.pad(\dojo.string.pad(\dojo.string.padLeft 使用字符补齐字符串开头 Usage Example:
dojo.string.padLeft(\dojo.string.padRight 使用字符补齐字符串结尾 Usage Example:
dojo.string.padRight(\dojo.string.substituteParams dojo.string.substitute
类似 C#中的 String.Format 函数
%{name}要保证与传入的对象的名称大小写一致,否则会出异常 dojo.require(\defined in dojo/string.js For example,
dojo.string.substitute(\'${1}'.\
dojo.string.substitute(\'${info.dir}'.\
{name: \both return
\Usage var foo=dojo.string.substitute(template: String, map: Object|Array, transform:
with the
Function?,
thisObject: Object?); parameter type
description template String a string with expressions in the form ${key} to be replaced or ${key:format} which specifies a format function. map
Object|Array hash to search for substitutions transform Function thisObject Object Usage Example: Optional. a function to process all parameters before substitution takes place, e.g. dojo.string.encodeXML
Optional. where to look for optional format function; default to the global namespace
dojo.string.substituteParams(\
dojo.string.substituteParams(\名称\值\名称: 值\模块:dojo.lang.common / dojo.lang
dojo.lang.common 和 dojo.lang 是一样的,只要 require 其中一个就可以使用以下方法 dojo.lang.inherits dojo.inherits
dojo.inherits = dojo.lang.inherits;
function(/*Function*/subclass, /*Function*/superclass){ // summary: Set up inheritance 继承 between two classes. dojo.lang.mixin dojo.mixin
dojo.mixin = dojo.lang.mixin;
将一个对象的方法和属性增加到另一个对象上 Usage Example:
var s1 = {name: \var s2 = {value: 1000, test2: function(){alert(\var d = {};
dojo.lang.mixin(d, s1, s2); //执行后 d 就具备了 s1 和 s2 的所有属性和方法 d.test1(); dojo.lang.extend dojo.extend
dojo.extend = dojo.lang.extend; 为指定类的原型扩展方法与属性
function(/*Object*/ constructor, /*Object...*/ props){ // summary:
//Adds all properties and methods of props to constructor's
//prototype, making them available to all instances created with //constructor. Usage Example:
TestClass = function() {};
dojo.lang.extend(TestClass, {name: \
var o = new TestClass(); //TestClass 本来是没有 test 方法的,但是 extend 以后就有 test 方法了 o.test(); dojo.lang.find
dojo.lang.indexOf
dojo.lang.indexOf = dojo.lang.find;
dojo.lang.find = function(/*Array*/ array, /*Object*/ value, /*Bollean*/ indentity, /*Boolean*/ findLast) // summary: //
Return the index of value in array, returning -1 if not found. // array: just what you think // value: the value to locate // identity: // //
If true, matches with identity comparison (===). If false, uses normal comparison (==). // findLast: // // //
If true, returns index of last instance of value. // examples:
find(array,value[, identity [findLast]]) // recommended find(value, array[, identity [findLast]]) // deprecated // support both (array, value) and (value, array) 查找指定对象在指定数组中的位置
返回值在数组中的索引值,-1 为未发现。
Indentity 为 true 匹配模式为(===),反正为(==) findLast 为 true 返回最后一个匹配值的索引。 Usage Example:
var arr = [1,2,3,3,2,1];dojo.lang.find(arr, 2);//will return 1 dojo.lang.find(arr, 2, true);//will return 1 dojo.lang.find(arr, \dojo.lang.find(arr, \
dojo.lang.find(arr, 2, true, true); //will return 4 dojo.lang.findLast
dojo.lang.lastIndexOf
dojo.lang.lastIndexOf = dojo.lang.findLast;
function(/*Array*/array, /*Object*/value, /*boolean?*/identity){ // summary: // // // // //
Return index of last occurance of value in array, returning -1 if not found. This is a shortcut for dojo.lang.find() with a true value for its \// identity:
If true, matches with identity comparison (===). If false, uses normal comparison (==).
查找指定对象在指定数组中的位置,从后往前查 Usage Example:
var arr = [1,2,3,3,2,1];dojo.lang.findLast(arr, 2);//will return 4 dojo.lang.findLast(arr, 2, true);//will return 4 dojo.lang.findLast(arr, \dojo.lang.findLast(arr, \dojo.lang.inArray
function(array /*Array*/, value /*Object*/){ // summary: Return true if value is present in array. 查找指定对象是否在指定数组中 Usage Example: var arr = [1,2,3];
dojo.lang.inArray(arr, 1);//will return true dojo.lang.inArray(arr, 4);//will return false dojo.lang.isObject
function(/*anything*/ it){ // summary: Return true if it is an Object, Array or Function. 判断输入的类型是否为对象 Usage Example:
dojo.lang.isObject(new String()); //will return true dojo.lang.isObject(\dojo.lang.isArray