2011-09-06 14 views
5

Sto provando a chiamare un'API con una richiesta POST. Ma il mio ispettore Chrome mi method='GET' nella scheda di rete mostra ...ExtJS 4 - Problemi con JsonStore + Post Request

Ecco il mio codice:

Ext.define('TestItem', { 
     extend: 'Ext.data.Model', 
     fields: [ 
      {name: 'id', type: 'int'}, 
      {name: 'name', type: 'string'} 
    ] 
    }); 

    var testStore = Ext.create('Ext.data.JsonStore', { 
     model: 'TestItem', 
     autoLoad: true, 
     proxy: { 
      type: 'ajax', 
      url : '../path_to/api/', 
      method : 'POST', 
      reader: { 
       type: 'json', 
       root: 'data', 
       totalProperty: 'total' 
      } 
     }, 
     baseParams: { 
      operation:'showall' 
     } 
    }); 

Quindi O vogliamo chiamare l'API con method='POST' e il parametro operation = showall

Gli spettacoli Google Inspector nella scheda di rete le seguenti informazioni:

GET ../path_to/api/?_dc=1315297478131&page=1&start=0&limit=25 HTTP/1.1 

Perché è una richiesta GET?

Perché ci sono alcuni parametri come limite, start e dc?

Ho già provato 1000 tutorial e googled tutta la notte.

+1

possibili duplicati [addes negozio extjs4 ottengono params nella url] (http://stackoverflow.com/questions/6925081/extjs4-store-addes-get-params-in-the-url/6926857#6926857) –

risposta

17

Nel metodo extjs4: il POST non funziona. In extjs4 qualsiasi lettura viene inviata da GET e qualsiasi scrittura (POST, PUT, DELETE) viene inviata dal POST. Per sovrascriverlo vedi actionMethods.

type: 'ajax', 
actionMethods: { 
    create : 'POST', 
    read : 'POST', 
    update : 'POST', 
    destroy: 'POST' 
} 
+0

Sì, grazie mille! – M00ly

+0

ma come faccio a impostare il corpo della richiesta ?? – Isaac

+0

+1 per la risposta. –