0
votes

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'
              }
            }
         }

});
1
you cannot sent POST request using JsonP.1Mayur
Can you please provide the code of how to that?chipmunk

1 Answers

0
votes
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'
    }
});

you json should have relative path, not absolute for ajax to work, cross domain can be achived via JSONP but you need to setup api with callback feature else it wont work