2012-08-26 2 views
0

.Net 서버에서 json 문자열을 읽는 상점이 있습니다. 문제는 sencha 앱이 결과가 없다는 것입니다 ("emptyText"). 이 가게는 더미 데이터와 함께 좋은 일했다 (자료 : [])하지만 난 문제에 봉착 프록시를 읽으려고 할 때Sencha touch 2 .net 서버에서 json을 읽을 수 없습니다.

상점 코드 :

Ext.define('myApp.store.myStore', { 
    extend: 'Ext.data.Store', 
    alias: 'widget.myStore', 
    autoLoad: true, 
    config: { 
     model: 'myApp.model.myModel', 
     proxy: { 
      type: 'scripttag', //Also tried ajax and jsonp 
      url: 'http://localhost:XXXX/ServerResponse/ReponseT.aspx?CityID=1', 
      reader: { 
       type: 'json' 
      } 
     } 
    } 

서버 코드 (C#을) :

리소스 스크립트로 해석하지만, MIME 타입 text/html과 함께 전송 : "URL

List<result> Li = new List<result>(); 
        result LR = new result() 
        { 
         id = 1, 
         Title = "Heu There"              
        }; 
        Li.Add(LR); 
string ans = JsonConvert.SerializeObject(Li, Formatting.Indented);  
Response.Write(ans); 

나는 경고가 "

은 그게 전부 ... 난 당신이 헤더 유형을 지정해야 몇 가지 중 하나가 내가

+0

사용중인 서버 유형은 무엇입니까? – hekomobile

답변

0

잘못하고 있어요 무슨 말을 할 수 있기를 바랍니다. 아래 코드는 .Net 서버에서 JSON 데이터를 가져 오는 데 사용됩니다.

Ext.Ajax.request({ 
      url: reqUrl, 
      defaultHeaders : 'application/json', 
      headers: { 
       "Accept": "application/json" 
      }, 
      useDefaultXhrHeader: false, 

      success : function(response, opt) { 
       benefitsRespObj = Ext.decode(response.responseText); 
       // your code goes here 
      } 
});