1

问候,

我正在尝试更改 appcelerator 中按钮上的文本。

现在我可以更改一次,但是一旦发生某些事件,我就无法将文本更改回来。

这是代码:

var login=Titanium.UI.createButton({
   title:'Login',
     width:250,
     top:330
});
win.add(login);
var xhr=Titanium.Network.createHTTPClient();
login.addEventListener('click', function(e){
     login.title="Please wait...";   //this line works fine
     xhr.onload=function(){
            login.title="Login";   //this line doesn't work
            if(uname.hasText){
                 uname.value=this.responseText;
            }
     };
     xhr.onerror=function(){
            login.title="Login";   //this line doesn't work
            alertDialog.show();
     };
     xhr.open("POST","http://www.asdf.com/ajax/login.php");
     if(uname.hasText && pword.hasText){
            xhr.send({"uname":uname.value,"pword":pword.value});
     }else{
            alertDialog.show();
     }
});

我现在根本不知道该怎么办!

任何见解都非常感谢。

提前谢谢了,

4

1 回答 1

0

您应该在 eventListener 中创建 HTTPClient

login.addEventListener('click', function(e){
    var xhr=Titanium.Network.createHTTPClient();
     xhr.onload=function(){};
     xhr.onerror =function(){};
     xhr.onreadysetstate =function(){};
}
于 2010-11-10T12:46:53.843 回答