1. #1
    Sencha User bytekast's Avatar
    Join Date
    Jun 2011
    Posts
    4
    Vote Rating
    0
    bytekast is on a distinguished road

      0  

    Exclamation Answered: JSONP Proxy generates wrong URL and ignores JSON Writer

    Answered: JSONP Proxy generates wrong URL and ignores JSON Writer


    I have the proxy defined in the model instead of the store...

    Code:
    Ext.define('Contact', {
        extend: 'Ext.data.Model',
        fields: ['id', 'name', 'email', 'message'],
        proxy: {
            type: 'jsonp',
            url : 'contact/jsonp',
        callbackKey: 'callback',
        reader: {
                type: 'json',
            root: 'contact'
            },
        writer: {
                type: 'json'
            }
        }
    });
    When I am executing a model.save(), the http request received by the server is not a JSON format and the first request parameter is ignored because of the "records=" in the URL. Is this a bug or am I missing something?

    http://localhost:8080/myapp/contact/...1320958562852&records=id=34&name=Test Name&email=test%40email.com&message=test&callback=Ext.data.JsonP.callback2

    Thanks.

  2. The problem is is that the method is going to be GET so the params will be appended onto the URL. Working with the POST method, you can transfer a JSON string in the POST body but JSONP will always be GET.

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,680
    Answers
    130
    Vote Rating
    112
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    Are you aware of the difference between an Ajax Proxy and JsonP?

    Take a look at the example on top of the page:
    http://docs.sencha.com/touch/2-0/#!/...ta.proxy.JsonP
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  4. #3
    Sencha User bytekast's Avatar
    Join Date
    Jun 2011
    Posts
    4
    Vote Rating
    0
    bytekast is on a distinguished road

      0  

    Default


    Yes i am aware of the difference. But this still does not explain the fact that the request parameters are not encoded in the JSON format when a JSON writer is specified.

    Also, the server code loses access to one of the request parameters because of this fragment in the url: "records=id=34". This means a records parameter with a value of id is stored in the request instead of the parameter id having a value of 34....

    Thanks

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The problem is is that the method is going to be GET so the params will be appended onto the URL. Working with the POST method, you can transfer a JSON string in the POST body but JSONP will always be GET.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 2

Tags for this Thread