当前位置: 首页 > 图文教程 > 网络编程 > Javascript > ext 同步和异步示例代码

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 ext 同步和异步示例代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-10   浏览: 397 ::
收藏到网摘: n/a

异步调用不用做过多说明,ext的api中支持的很多。 同步调用的相关文档就少一些。一下是同步示例,即页面在加载时,或者这个js被调用到时,程序会一行一行的往下走,这在获取页面初始化需要数据或者样式等一些功能会用到。
示例代码:
复制代码 代码如下:

//判断按钮权限的方法。true为无权限,false为有权限可以显示
function checkButton(buttonId){
//按钮的状态,ext对类型要求比较高,这里注意类型、变量的转换问题。
var state = new Boolean(true);
//这里调用的是ext的同步方法,要和异步的调用区别开来
var conn = Ext.lib.Ajax.getConnectionObject().conn;
//第二个参数是向后台请求的地址,请求的后台方法输出数据即为:conn.responseText数据
conn.open("get", '/base/business/SysPublicAction.do?operate=checkButtonsState&buttonId='+buttonId,false);
conn.send(null);
//conn.responseText为字符串类型
//不能将字符串赋值给state,所以这里只能进行判断字符来进行state的改变
if(conn.responseText=="false")
state = new Boolean(false);
return state.valueOf();
}
'