2010-12-04 33 views
2

我嘗試用下面的代碼,我得到錯誤:無效的標籤錯誤:無效的標籤時,我嘗試從URL煎茶觸摸JSON

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

我在瀏覽器中粘貼了該代碼,它對我很有用。你可以向我解釋爲什麼你這樣啓動一個JSONP請求,而不是使用帶有ScriptTagProxy的模型? – Ballsacian1 2011-06-22 17:53:08

回答

1

你也可以使用Ajax請求而不是JSONP,下面是代碼示例。這對我有用。

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