1. #1
    Sencha User
    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 - Services Team tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,292
    Vote Rating
    6
    Answers
    57
    tobiu will become famous soon enough

      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
    __________


    Sencha Inc
    Tobias Uhlig, Solutions Engineer

    Private Projects:

    S-CIRCLES Social Network Engine
    Commercial Theming for Ext JS 3 & 4

  4. #3
    Sencha User
    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
    St. Louis, MO
    Posts
    33,641
    Vote Rating
    434
    Answers
    3107
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      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
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

Tags for this Thread