1

With GET method, i easily get this reponse. But POST method i don't get it.

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

What i wrong?

Chu Bao .Dev
  • 319
  • 2
  • 14
  • You can't use POST with JSONP. It uses the ` – Rob Jun 18 '13 at 08:58
  • Thanks, Rob. So, how i can fix it.? – Chu Bao .Dev Jun 18 '13 at 09:19
  • You could take a look at `Ext.Ajax`, or you could use GET and send your post_data as URL-parameters. – Rob Jun 18 '13 at 09:30
  • I am building a Sencha Touch webapp. I tried posting with Ext.Ajax( method: "POST") to my domain without localhost service, but it have a problem relate to Browser Policy Security - Access-Control-Allow-Origin error - just use jsonP to get. So, I can use which way? – Chu Bao .Dev Jun 18 '13 at 09:48
  • You will either have to implement CORS or you will have to only use GET-methods to communicate with your webservice. – Rob Jun 18 '13 at 09:53

2 Answers2

1

You cannot call any webservice from your browser because of security reasons so either you have to use JSONP proxy on app side or you have to enable CORS on your server side. If you are planning to build this as app then you don't have to do this, all you have to do is change security setting of your browser when you are testing. More details here : How to use json proxy to access remote services during development

Community
  • 1
  • 1
ThinkFloyd
  • 4,981
  • 6
  • 36
  • 56
0

Yes,it worked! ^^ Sencha Touch is a client-side(a Mobile Web App) or builded it localhost, it will have CORS - a browser policy security - related to your using ajax in it. So, I configed all api in my PHP server by add 2 code rows:

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


}

Thank for Rob's help! Hope you have similar problem fix error successfully.

Chu Bao .Dev
  • 319
  • 2
  • 14