2013-06-18 19 views
1

使用GET方法,我很容易得到這個響應。但POST方法我不明白。JSONP - Sench Touch 2.1中的POST方法

Ext.data.JsonP.request({ 
      url: 'http://otherdomain/test_json_post', 
      method: 'POST', 
      type:'jsonp',  
      scope: this,  
      callbackkey: 'callback', 
      success: function(result) { 
       console.log(result); 
       //Your success function here... 
      } 
     }); 

我錯了什麼?

+0

您不能在JSONP中使用POST。它使用'

0

是的,它的工作!^Sencha Touch是客戶端(移動Web應用程序)或將其構建爲本地主機,它將具有CORS(瀏覽器策略安全性),與您在其中使用ajax相關。所以,我在我的PHP服務器中通過添加2個代碼行來配置所有api:

function yourAPI 
{ 
    //CORS open 
    header('Access-Control-Allow-Origin: *'); 
    header('Access-Control-Allow-Headers: X-Requested-With'); 
    .... 
    {enter your code here} 


} 

感謝Rob的幫助!希望你有類似的問題修復錯誤成功。