Javascript 将对象值传递给钛合金中的for循环

Javascript 将对象值传递给钛合金中的for循环,javascript,for-loop,titanium,titanium-mobile,Javascript,For Loop,Titanium,Titanium Mobile,我是钛合金新手,希望显示我的对象所在的远程服务器数据 Object todo: Array[2] 0: Object todo: "Khaleeq Raza" __proto__: Object 1: Object todo: "Ateeq Raza" __proto__: Object length: 2 __proto__: Array[0] __proto__: Object VM90:10 我的代码是用钛合金编写的,用于创建行并希望放置数据

我是钛合金新手,希望显示我的对象所在的远程服务器数据

Object
 todo: Array[2]
  0: Object
   todo: "Khaleeq Raza"
   __proto__: Object
  1: Object
   todo: "Ateeq Raza"
  __proto__: Object
 length: 2
 __proto__: Array[0]
 __proto__: Object
  VM90:10
我的代码是用钛合金编写的,用于创建行并希望放置数据

    var client = new XMLHttpRequest();
    client.open("GET", "http://192.168.1.109/read_todo_list.php", true);
    client.send();
    client.onreadystatechange = function(){

    if (client.readyState==4 && client.status==200)
        {

            json = JSON.stringify(client.response);
        var get=JSON.parse(json);

        for( var i=0; i<get.length; i++){

        var row = Ti.UI.createTableViewRow({
            title: get[i].todo,
            hasChild : true,
            });     
            dataArray.push(row);                
        }

        $.tableView.setData(dataArray);

        }

    };
var-client=new-XMLHttpRequest();
client.open(“GET”http://192.168.1.109/read_todo_list.php“,对);
client.send();
client.onreadystatechange=函数(){
if(client.readyState==4&&client.status==200)
{
json=json.stringify(client.response);
var get=JSON.parse(JSON);

对于(var i=0;i在Tianium中没有
XMLHttpRequest
,下面是一种获取数据的简单方法(假设服务器配置正确且没有身份验证)

var client=Ti.Network.createHTTPClient({
//响应数据可用时调用的函数
onload:函数(e){
Ti.API.info(“接收到的json:+this.responseText”);
//解析JSON
var object=JSON.parse(this.responseText);
//获取数组
var todo=object.todo;
//创建表行
var dataArray=[];

对于(var i=0;iYou已经发布了三次相同的问题..感谢您的回复,但这会产生问题,并且在我回复时使用XMLHttpRequest可以很好地工作。您说XMLHttp不应该在Tianium中使用,尽管它可以工作。请您给我一个关于Tianium购物车的建议。我有Codiegniter应用程序。我想开发相同的like在Tianium中这是可以在Alloy中设计HTML等的,请表示感谢您是对的,我的代码仅在pc浏览器中运行,不在andriod应用程序中。但存在错误:加载资源失败:访问控制允许标头不允许请求标头字段X-Tianium-Id
var client = Ti.Network.createHTTPClient({
     // function called when the response data is available
     onload : function(e) {
         Ti.API.info("Received json: " + this.responseText);
         // Parse JSON
         var object = JSON.parse(this.responseText);
         // Get the array
         var todo = object.todo;
         // Create table rows
         var dataArray = [];
         for( var i=0; i<todo.length; i++){
             var row = Ti.UI.createTableViewRow({
                 title: todo[i].todo,
                 hasChild : true,
              });     
              dataArray.push(row);                
         }
         $.tableView.setData(dataArray);

         alert('success');
     },
     // function called when an error occurs, including a timeout
     onerror : function(e) {
         Ti.API.debug(e.error);
         alert('error');
     },
     timeout : 5000  // in milliseconds
 });
 // Prepare the connection.
 client.open("GET","http://192.168.1.109/read_todo_list.php");
 // Send the request.
 client.send();