+ -
当前位置:首页 → 问答吧 → Ext.Ajax.request() 在外面取值不成功。

Ext.Ajax.request() 在外面取值不成功。

时间:2011-03-30

来源:互联网

这个要怎么才能取到值呢?
JScript code

function jihuaType(){
    var jihuatype="";
    Ext.Ajax.request({
                method:'POST',
                url:'GetTopFieldText.aspx?FieldId=0&nosearch=1',
                success:function(response,options){
                    Ext.Msg.alert('提示', "网络连接成功!");
                    //jihuatype = response.responseText;
                    jihuatype = response.responseText;
                },
                failure : function(response, options) {
                    Ext.Msg.alert('提示', "网络连接错误!");
                    jihuatype="ERROR";
                }
            });
    var start=new Date().getTime() ;
    while(true) {
            if(jihuatype != "") {
                break ;
            }else if(new Date().getTime()-start>3000){
                break;
            }
        }
    return jihuatype;
}

作者: wranglergu   发布时间: 2011-03-30

有解吗? 如果能判断他的异步读取到数据之后再return就好了。 需要怎么做呢。

作者: wranglergu   发布时间: 2011-03-30