Results 1 to 4 of 4

Thread: JSONP Proxy generates wrong URL and ignores JSON Writer

  1. #1
    Sencha User bytekast's Avatar
    Join Date
    Jun 2011
    Posts
    4
    Vote Rating
    0
      0  

    Exclamation 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,750
    Answers
    130
    Vote Rating
    128
      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

  4. #3
    Sencha User bytekast's Avatar
    Join Date
    Jun 2011
    Posts
    4
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •