如题我调用如下方法 function Test(value, metadata, record, rowIndex, colIndex, store) {
var text = value;
Ext.net.DirectMethods.getText(value, colIndex, {
async: true,
success: function (result) {
text = result;
}
}); return text;
}
我要让这个text返回result数据,照理应该是先在Success里赋值,然后再return,结果设置了async: true没用,每次都是return后再赋值的
var text = value;
Ext.net.DirectMethods.getText(value, colIndex, {
async: true,
success: function (result) {
text = result;
}
}); return text;
}
我要让这个text返回result数据,照理应该是先在Success里赋值,然后再return,结果设置了async: true没用,每次都是return后再赋值的
解决方案 »
- 本地存储localstorage 存一些数据,我想设个时间,让它当天0点过期,第二天重新存,怎么设置过期
- 如何用js生成类似google form的动态表单?
- javascript 无法保存cookie
- 如何在js函数里改变html页面上的控件的标题阿
- 关于javascript的重载
- 请问这几个属性是做什么的?
- 如何用正则表达式,将e.innerHTML中"<br>" 替换成js 的换行
- 请问怎么把本地的网页调整大小
- 如何把javascript的非法字符加上转义符号?
- 救命~救命~大神在哪里?新做的网站即将上线时,遇到了在浏览时浏览器崩溃的情况
- 高手们 js怎么判断鼠标是否在标签上 但是不用事件判断 求高手帮忙
- jQuery 判断显示隐藏
function Test(value, metadata, record, rowIndex, colIndex, store) {
var text = value;
Ext.net.DirectMethods.getText(value, colIndex, {
async: true,
success: function (result) {
text = result;
return text;
}
});
}如果那头需要反回就使用数据,你还可以这样写 function Test(value, metadata, record, rowIndex, colIndex, store) {
var text = value;
Ext.net.DirectMethods.getText(value, colIndex, {
async: true,
success: function (result) {
text = result;
f(text);//直接把函数放进来.
}
}); }
同步请求过程中页面卡死在那,若通讯失败,得一直卡到请求超时为止,这种怎么都觉得体验很差你这儿不行的原因要从 Ext.net.DirectMethods.getText函数中找了,若其内部用了什么异步的方式发ajax请求(比如setTimeout),那么尽管ajax请求是同步的,但当前函数却并不会阻塞
function Test(value, metadata, record, rowIndex, colIndex, store) {
var text = value;
Ext.net.DirectMethods.getText(value, colIndex, {
async: true,
success: function (result) {
text = result;
return text;
}
});
}
var text = value;
Ext.net.DirectMethods.getText(value, colIndex, {
async: true,
success: function (result) {
text = result;
if(callback) {
callback(text);
}
}
});
}
然后你可以这样调用:
Test(..., ..., ..., ..., ..., ...,function(result){
alert(result);
});
这样result参数就是服务器返回的值