2010-12-04 4 views
2

からJSONを取得しようとすると、私は次のコードで試してみて、私はエラーを取得:無効なラベルエラー:無効なラベル私は、URLの煎茶タッチ

Ext.util.JSONP.request({ 
      url: 'http://demo.webfactory.mk/', 
      callbackKey: 'callback', 
      params: { 
       action: 'retrieve', 

      }, 
      callback: function(data) { 
       console.log('Inside data'); 
       var dataarray = data.result; 
       console.log(dataarray); 

      } 

    }); 
+0

私のブラウザにこのコードを貼り付けてくれました。 ScriptTagProxyでモデルを使用する代わりに、JSONPリクエストをこのように開始する理由を説明できますか? – Ballsacian1

答えて

1

またある以下、代わりにJSONPのAjaxリクエストを使用することができますコードサンプル。これは私のために働く。

Note that you cannot make cross domain Ajax calls, in chrome so u cant test in chrome. You need to deploy your Sencha script to the same Web server you are accessing. But All mobile browser supports this cross domain Ajax calls.

先に進んで実装します。

Ext.Ajax.request({ 
     url: reqUrl, 
     defaultHeaders : 'application/json', 
     success : function(response, opt) { 
      dataarray = Ext.decode(response.responseText); 
      //App.views.viewport.reveal('nextScreen'); 
     }, 
     failure : function(response, opt) { 
      Ext.Msg.alert('Failed', response.responseText); 
     } 
    }); 
関連する問題