【问题标题】:Sencha Touch ScriptTagProxy only works on localhost and not pulling a remote source?Sencha Touch ScriptTagProxy 仅适用于 localhost 而不能拉取远程源?
【发布时间】:2011-10-07 20:48:52
【问题描述】:

我已经花了几天时间试图让我的 Sencha Touch 应用程序工作,以便它使用 JSON 提要来填充新闻表,下面的代码现在可以在 localhost 上正常工作,但只要我更改行

url: 'http://localhost/list.php',

到远程服务器:

url: 'http://www.myserver.com/list.php',

然后应用程序加载失败并且总是遇到超时监听器,我尝试将超时监听器增加到 20000 但仍然无法加载?

console.log(response.responseText);也无法显示任何内容。

谢谢亚伦

Ext.regStore('NotesNewsStore', {

    model: 'NoteNewsModel',

   offLineStore: new Ext.data.Store({
            model: 'photo',
            proxy: {
                type: 'localstorage',
                id: 'notes-app-store1'
            }
        }),

    proxy: {

        type: 'scripttag',
        url: 'http://localhost/list.php',
        reader: new Ext.data.JsonReader({

        }),        

        timeout:1000,
        listeners: {
            exception: function(proxy, response, operation) {
                console.log("I Think we are offline");
                    console.log(response.status);
            console.log(response.responseText);
            }
        }
   }
}); 

【问题讨论】:

    标签: javascript extjs sencha-touch script-tag


    【解决方案1】:

    检查远程服务器是否配置为使用脚本标签,例如:

    $callback = $_REQUEST['callback'];
    
    // Create the output object.
    $output = array('a' => 'Apple', 'b' => 'Banana');
    
    //start output
    if ($callback) {
        header('Content-Type: text/javascript');
        echo $callback . '(' . json_encode($output) . ');';
    } else {
        header('Content-Type: application/x-json');
        echo json_encode($output);
    }
    

    【讨论】:

      猜你喜欢
      • 2011-08-02
      • 1970-01-01
      • 1970-01-01
      • 2012-10-11
      • 1970-01-01
      • 1970-01-01
      • 2015-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多