【问题标题】:Unable to send GET request from Titanium Studio (Android Emulator)无法从 Titanium Studio(Android 模拟器)发送 GET 请求
【发布时间】:2011-11-12 17:40:09
【问题描述】:

我是这个领域的新手。我正在从事 Android 应用程序开发。我正在使用 Titanium Studio 进行开发。目前我正在开发登录组件。我正在使用以下代码:

var win = Titanium.UI.currentWindow;

var username = Titanium.UI.createTextField({
color:'#336699',
top:10,
left:10,
width:300,
height:40,
hintText:'Username',
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(username);

var password = Titanium.UI.createTextField({
color:'#336699',
top:60,
left:10,
width:300,
height:40,
hintText:'Password',
passwordMask:true,
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(password);

var loginBtn = Titanium.UI.createButton({
title:'Login',
top:110,
width:90,
height:35,
borderRadius:1,
font:{fontFamily:'Arial',fontWeight:'bold',fontSize:14}
 });
win.add(loginBtn);

var loginReq = Titanium.Network.createHTTPClient();
loginBtn.addEventListener('click',function(e)
{
    if (username.value != '' && password.value != '')
{
    loginReq.open("GET","http://localhost:3000");
}
else
{
    alert("Username/Password are required");
}
});
 

但它不工作并且不发送 GET 请求。

【问题讨论】:

    标签: javascript dom-events titanium


    【解决方案1】:

    在你的 HTTPClient 上调用 send()

    loginReq.open("GET","http://localhost:3000");
    loginReq.send();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多