`

ExtJS同步请求

 
阅读更多

一、ext3.0之前都是如下方式同步请求:
     var conn= Ext.lib.Ajax.getConnectionObject().conn;
     responsea.open("POST/GET", url,false/true);
     responsea.send(null);

     var resp = conn.responseText;

二、Ext3.0版本的实现方式 需要引入ext-basex.js

     

Ext.Ajax.request({
					    	url : 'checkRadomCode.do',//异步校验的时机有问题
					    	params : {randCode:Ext.getCmp("randCodeId").getValue()},
					    	scope : true,
					    	method: 'POST',
					    	async: false ,
					    	success: function(response, opts) {  
                				if(response.responseText=="true"){
					    		     returnValue(true);
					    		  } else if(response.responseText=="false"){
					    			  Ext.Msg.alert("提示","验证码输入错误!");
					    			  Ext.getCmp("randCodeId").markInvalid("验证码输入错误!");
					    		    returnValue(false);
					    		  }
					    	}, //请求成功的回调函数   
                			failure: function() { Ext.Msg.alert("提示","请求数据库失败请重试!"); }  // 请求失败的回调函数
					});//同步加载
						function returnValue(ok){
							IsRandomRright = ok;
						}
						return IsRandomRright;
		       }//end_validator
			}//验证码

    同时将新引入的js文件打开将if(callback && callback.timeout){  

改为 if(callback && callback.timeout && options.async){  

对于压缩版 if(u&&u.timeout){”改为“if(u&&u.timeout&&n.async){”

或者('timeout' in r) && (r.timeout = callback.timeout);改为(options.async) && ('timeout' in r) && (r.timeout = callback.timeout);  

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics