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 に答える