Titanium 无法在中打开远程服务器文件

Titanium 无法在中打开远程服务器文件,titanium,titanium-mobile,titanium-alloy,Titanium,Titanium Mobile,Titanium Alloy,我想从服务器获取远程数据,但这会导致连接未执行的错误 并在Chrome浏览器的控制台中显示 Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8020' is therefore not allowed access. XMLHttpRequest cannot load http:/

我想从服务器获取远程数据,但这会导致连接未执行的错误

并在Chrome浏览器的控制台中显示

Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the    requested resource. Origin 'http://127.0.0.1:8020' is therefore not allowed access.

XMLHttpRequest cannot load http://domeain.com/json.txt. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8020' is therefore not allowed access. 
我的代码是

  function getTodoList (){
    var sendit = Ti.Network.createHTTPClient();
             sendit.open('GET', 'http://domain.com/json.txt');  
             sendit.onload = function(){
        var json = JSON.parse(this.responseText);
        var json = json.todo;
        //if the database is empty show an alert
        if(json.length == 0){
            $.tableView.headerTitle = "The database row is empty";
        }
          dataArray = [];
          for( var i=0; i<json.length; i++)
        {
            var row = Ti.UI.createTableViewRow({
                title: json[i].todo,
                hasChild : true,
            });     
            dataArray.push(row);                
        }

            $.tableView.setData(dataArray);

         };
         sendit.onerror = function(){
                Ti.API.debug(e.error);
                alert('There was an error during the conexion');
         };
         sendit.setTimeout(10000); // 10 sec for timeout

            sendit.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            sendit.setRequestHeader("Access-Control-Allow-Origin", "*");

         sendit.send();
    }
函数getToList(){ var sendit=Ti.Network.createHTTPClient(); sendit.open('GET','http://domain.com/json.txt'); sendit.onload=函数(){ var json=json.parse(this.responseText); var json=json.todo; //如果数据库为空,则显示警报 if(json.length==0){ $.tableView.headerTitle=“数据库行为空”; } dataArray=[];
对于(var i=0;这不是钛合金问题,而是服务器问题。您有。钛合金代码看起来不错。@Joshiah感谢您的同意,但我如何在浏览器中启用这些,或者如何使用这些权限设置头文件。在sendit.setRequestHeader(“访问控制允许源文件”、“*”)等代码中是否有设置这些权限的选项;我已经在用了。