2014-04-05 3 views
2

안녕하세요 모두 저는 버튼 클릭으로 웹 서비스를 호출해야하고 JSON을 구문 분석해야하는 sencha 애플리케이션에서 작업하고 있습니다.웹 서비스를 호출하고 sencha에서 json을 구문 분석하는 방법은 무엇입니까?

나는 이것을 많이했지만 단계별 튜토리얼로 어떤 단계도 얻지 못했습니다. 나는 sencha에 웹 서비스를 호출하고 sencha touch에서 json을 파싱하기위한 단계별 자습서가 필요하다.

가 내 기능

을 :

getDetails: function(){ 

       alert("Hi Welcome To Sencha"); 
        Ext.Ajax.request({ 
         method: 'GET', 
         url: 'http://www.aswaq.se/web_ajax_disp.php?fid=100&n=rt&p=rt', 
         params: { method: 'Helloworld', format: 'json' }, 
         success: function (response, request) { 
          alert('Working!') 
          alert(response.responseText) 
          console.log('Response:-' + response.responseText) 
         }, 
         failure: function (response, request) { 
          alert('Not working!') 
          console.log('Response Status:- ' + response.status) 
         } 
        }); 
     } 

도움을 주시면 감사하겠습니다

은 또한 아래의 일부 코드를 시도했다.

답변

1

질문에 간단하고 직접적인 대답은 다음과 같습니다

var myStore = Ext.create("Ext.data.Store", { 
    model: "User", 
    proxy: { 
     type: "ajax", 
     url : "/users.json", 
     reader: { 
      type: "json", 
      rootProperty: "users" 
     } 
    }, 
    autoLoad: true 
}); 

을 : 그것은 다음과 같은 :

Ext.Ajax.request({ 
    method: 'GET', 
    url: 'http://www.aswaq.se/web_ajax_disp.php?fid=100&n=rt&p=rt', 
    params: { method: 'Helloworld', format: 'json' }, 
    success: function (response, request) { 
     alert('Working!') 
     var jsonData = Ext.util.JSON.decode(response.responseText); 
    }, 
    failure: function (response, request) { 
     alert('Not working!') 
     console.log('Response Status:- ' + response.status) 
    } 
}); 

그러나 엽차 터치 2에 extjs 지침 stores 사용 권 해드립니다 상점을로드하면 자동으로 지정된 올바른 URL이 호출되고 지정한 모델 (모델 : 사용자)에 따라 데이터가로드됩니다. 두 가지 방법으로 상점을로드 할 수 있습니다. 예와 같이 autoLoad : true를 설정하고 앱에로드 할 때 저장소로드 허용 원하는 경우 myStore.load()를 호출하십시오.

관련 문제