0

hi am new to Sencha touch2, am facing problem while fetching data from a remote url. When i use the url in simple rest client am able get data and with status: 200 ok. Here is input of simple rest client for your reference.

---------------
url: http://190.40.2.14:9030/work
Method: post
Headers:Accept: application/json
Data:<workTO><platform>ALL</platform></workTO>
---------------

how can i use post request, headers and data how can i do this in Sencha touch2.

here is the model with proxy:

Ext.define('TestApp.model.myModel', {
    extend: 'Ext.data.Model',
    xtype:'modelList',
    config: {
               fields:['work'],

            proxy:{
             type:'rest',
//                url:'http://localhost:9090/TestApp/app/store/sample.json',// this works
               url:'http://10.30.2.141:9030/work',

              reader:
              {
                 type:'json'
              }
            }
         }

});
4

1 回答 1

0
Ext.define('TestApp.model.ModelList', {
    extend: 'Ext.data.Model',
    xtype:'modelList',
    config: {
            fields:['task'],
            proxy:{
                  type: 'ajax',
                  url:'http://localhost:9090/TestApp/app/store/sample.json',
                  callbackKey: 'theCallbackFunction'
            },    
            reader: 'json'
    }
});

你的 json 应该有相对路径,而不是绝对的 ajax 工作,跨域可以通过 JSONP 实现,但你需要设置带有回调功能的 api,否则它不会工作

于 2013-04-08T16:10:10.743 回答