1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    77
    Answers
    6
    Vote Rating
    1
    azamatoak is on a distinguished road

      0  

    Default Answered: Can't set Store Proxy method to POST

    Answered: Can't set Store Proxy method to POST


    I am having trouble with trying to set the method to POST for a store proxy. It seems to default to GET and I can't find the proper place to set the method in the documentation. When I run this from the console as so:

    Code:
    var s = Ext.getStore('venuesStore');
    s.load();
    I can see that the request is sent using the GET method.

    Here's my code:

    Code:
    Ext.define('EventsTest.store.Venues', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'Ext.data.proxy.JsonP',
        ],
    
    
        config: {
            storeId: 'venuesStore',
            model: 'EventsTest.model.Venue',
            proxy: {
                type: 'jsonp',
                url: 'http://app.onetouchrecycle.ca/index.php/api/get_listings',
                callbackKey: 'dataReceived',
                //method: 'POST',
                actionMethods: {
                    read: 'POST'
                },
                extraParams: {
                    latitude: 45.250157,
                    longitude: -75.800257,
                    radius: 5000
                }
            }
        },
    
    
        dataReceived: function(d) {
            console.log(d);
        }
    });

  2. You can't use JsonP to send a POST request: stating that you are using JsonP, automatically overrides any method type to GET b/c that is the only method it supports.
    Read this http://stackoverflow.com/questions/2...-data-to-jsonp

    I'm guessing you are using JsonP to avoid getting the Cross-site scripting error. If you really need to use the POST method for your request, I suggest you use a server-side language like PHP to act as a middle man to complete your requests and allow your client side(Sencha) to use the server-side to by changing the access control, read the following link on how to do that:
    http://stackoverflow.com/questions/1...l-allow-origin

    But in keep in mind that this method isn't very secure, at the very least, I would make use of some random string URL that isn't easy to guess and maybe pass security tokens etc with each request from your Sencha App as well and check them on your server-side to make sure that only 'legitimate' requests are served.

    Let me know if you any questions regarding this method. I probably missed a few details.

  3. #2
    Sencha User
    Join Date
    Oct 2012
    Posts
    12
    Answers
    2
    Vote Rating
    1
    talwinder is on a distinguished road

      0  

    Default JsonP doesn't support POST, only GET

    JsonP doesn't support POST, only GET


    You can't use JsonP to send a POST request: stating that you are using JsonP, automatically overrides any method type to GET b/c that is the only method it supports.
    Read this http://stackoverflow.com/questions/2...-data-to-jsonp

    I'm guessing you are using JsonP to avoid getting the Cross-site scripting error. If you really need to use the POST method for your request, I suggest you use a server-side language like PHP to act as a middle man to complete your requests and allow your client side(Sencha) to use the server-side to by changing the access control, read the following link on how to do that:
    http://stackoverflow.com/questions/1...l-allow-origin

    But in keep in mind that this method isn't very secure, at the very least, I would make use of some random string URL that isn't easy to guess and maybe pass security tokens etc with each request from your Sencha App as well and check them on your server-side to make sure that only 'legitimate' requests are served.

    Let me know if you any questions regarding this method. I probably missed a few details.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar