2011-09-06 10 views
5

POST isteğiyle bir API'yi aramaya çalışıyorum.ExtJS 4 - JsonStore + Gönderme İsteği ile İlgili Sorunlar

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

Yani O method='POST' ile API ve parametreyi operation = showall

tarihinde Müfettiş gösterileri aramak istiyorum: Ama Krom Müfettiş İşte

kodum var ... bana ağ sekmesinde method='GET' gösterir ağ sekmesinde şu bilgiyi ekleyin:

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

Neden bir GET isteği?

Neden limit, start ve dc gibi parametreler var?

Zaten 1000 ders çalıştım ve bütün gece internete girdim.

+1

olası yinelenen ([extjs4 mağaza ADDES url params olsun] http://stackoverflow.com/questions/6925081/extjs4-store-addes-get-params-in-the-url/6926857#6926857) –

cevap

17

extjs4 yönteminde: POST çalışmıyor. Extjs4'te herhangi bir okuma GET ile gönderilir ve herhangi bir yazma (POST, PUT, DELETE) POST ile gönderilir. Bunu geçersiz kılmak için actionMethods konusuna bakın.

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

Evet, çok teşekkürler! – M00ly

+0

ama istek gövdesini nasıl ayarlayabilirim? Cevap için – Isaac

+0

+1. –