2011-09-06 7 views
5

POST 요청으로 API를 호출하려고합니다.ExtJS 4 - JsonStore + Post 요청의 문제

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

그래서 O가 method='POST'과 API 및 매개 변수 operation = showall

구글 검사기 프로그램을 호출 할 :하지만 내 크롬 인스펙터는 여기

내 코드의 ... 나 네트워크 탭에서 method='GET' 보여줍니다 나 네트워크 탭에서 다음 정보 :

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

왜 GET 요청입니까?

왜 limit, start 및 dc와 같은 매개 변수가 있습니까?

나는 이미 1000 개의 자습서를 시도하고 밤새도록 인터넷 검색을 시도했다.

+1

가능한 중복 ([extjs4 저장 addes URL에 PARAMS을 얻을] http://stackoverflow.com/questions/6925081/extjs4-store-addes-get-params-in-the-url/6926857#6926857) –

답변

17

extjs4 방법에서 : POST가 작동하지 않습니다. extjs4에서는 모든 읽기가 GET에 의해 보내지고 쓰기 (POST, PUT, DELETE)는 POST에 의해 보내집니다. 이를 무시하려면 actionMethods를 참조하십시오.

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

그래, 정말 고마워! – M00ly

+0

하지만 요청 본문은 어떻게 설정합니까 ?? 대답은 – Isaac

+0

+1입니다. –