2011-05-04 5 views
0

교착 상태에 있기 때문에 연락을드립니다. "ScriptTag"를 사용하여 extern 웹 서비스에서 데이터를 가져 오려고하지만 웹 서비스가 간단한 json 형식 (JSONP 없음)을 반환하기 때문에 작동하지 않습니다.Sencha Touch - 오류 - JSON 복구

sencha를 사용하여 json을 검색하는 다른 방법이 있는지 알고 계십니까?

var helloWorld = new Ext.Application({ 

Parking: Ext.regModel('Parking', { 
    fields:[ 
     {name:'parkingName'}, 
     {name:'latitude'}, 
     {name:'longitude'}, 
     {name:'mapUrl'} 
    ], 
}), 

launch: function() { 
    this.tabs = new Ext.TabPanel({ 
     fullscreen: true, 
     dockedItems: [{xtype:'toolbar', title:'JSON Recovery'}], 
     tabBar: { 
      ui: 'light', 
      layout: { 
       pack: 'center' 
      } 
     }, 
     items: [ 
      {cls:'Page1', title:'Page1', html:'Page1'}, 
      { 
       cls: 'list', 
       title: 'Page2', 
       xtype: 'list', 
       loadingText: 'Chargement', 
       itemTpl:'<div>{parkingName}</div>', 
       store: new Ext.data.Store({ 
        autoLoad:true, 
        model: 'Parking', 
        proxy: { 
         type: 'scripttag', 
         url : 'http://walker.hotcity.lu/hotcity-central-server/webresources/parking/json?format-version=1_0&client-type=iPhone', 
         reader: { 
          type: 'json', 
          root: 'remoteObject' 
         },      
        } 
       }), 

      }, 
     ], 

    }); 

} 

});

warning : Resource interpreted as Script but transferred with MIME type application/json.

error : Uncaught SyntaxError: Unexpected token :

감사합니다.

케빈.

답변

0

당신이 찾고있는 것은 Ajax Proxy입니다. 문서 사용 방법과 구성 방법에 대한 몇 가지 예가 있습니다. 기본 독자는 JSON이므로 모델이 JSON을 통해 검색된 정보와 일치하는 한 괜찮을 것입니다.

JSONP는 크로스 사이트 스크립팅을 사용할 수 있지만 walker.hotcity.lu 도메인에 배포하지 않으면 브라우저가 same origin policy으로 인해 요청을 허용하지 않는다는 점에 유의해야합니다. . 서버는 앱이 데이터에 액세스 할 수 있도록 적절한 CORS 헤더로 응답해야합니다.