Dojo入门教程之dojo.io.bind详解
dojo.io.bind :处理请求取回需要的数据并处理。
dojo.io.bind(
{
url:"http://localhost/test.html",//要请求的页面地址 mimetype:"text/html",//请求的页面的类型,应该设置为与你请求页面类型对应的mimetype,默认为"text/plain" method:"GET",//默认为"GET" sync:false,//默认为异步执行 useCache:false,//默认为不使用页面缓存,注意这里的缓存并不是浏览器的缓存,而是Dojo自身所维护的页面缓存 preventCache:false,//默认为启用浏览器缓存,否则将通过自动增加不同的参数来确保浏览器缓存失效 timeoutSeconds:3000,//3秒后超时,如果为0则永不超时 load:function(type,data,evt){alert(data);},//typeshouldbe"load",dataisthatwewanted error:function(type,error){alert(error.message);},//errorisdojo.io.Error timeout:function(type){alert("请求超时!");} } );
dojo.io.bind(
{
url:"http://localhost/test.html",//请求的页面的类型,应该设置为与你请求页面类型对应的mimetype timeoutSeconds:3000,//3秒后超时,如果为0则永不超时 handle:function(type,evt){ if(type=="load"){alert(data);}//dataisthatwewanted elseif(type=="error"){alert(data.message);}//dataistheerrorobject else{;}//othereventsmaybeneedhandled } } );
dojo.io.bind(
{
url:"http://localhost/test.html",//3秒后超时,如果为0则永不超时 transport:"XMLHTTPTransport", load:function(type,evt){alert(data);},error){alert(error.message);},//errorisdojo.io.Error timeout:function(type){alert("请求超时!");} } );
testObj
=
dojo.io.bind(
{
url:"http://localhost/test.js",//test.js里定义了一个对象 mimetype:"text/javascript",//3秒后超时,如果为0则永不超时handle:function(type,evt){ if(type=="load"){alert(data);}//dataisaobjectorvalue elseif(type=="error"){alert(data.message);}//dataistheerrorobject else{;}//othereventsmaybeneedhandled } });
dojo.io.bind(
{
url:"http://localhost/test.aspx",//要提交的页面地址 mimetype:"text/html",//3秒后超时,如果为0则永不超时 method:"POST", formNode:dojo.byId("myForm"),//指定提交的Form名称 load:function(type,evt){alert(data);},error){alert(error.message);},//errorisdojo.io.Error timeout:function(type){alert("请求超时!");} } );
dojo.io.bind(
{
url:"http://localhost/test.aspx", content:{a:1,b:2},//要提交的数据 load:function(type,evt){alert(data);},error){alert(error.message);},//errorisdojo.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 "c=3&b=2&a=1" dojo.io.argsFromMap({name:"名称",value:"值"},"utf"); //will return "value=? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |