-
10 Nov 2011 1:38 PM #1
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...
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?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' } } });
http://localhost:8080/myapp/contact/...1320958562852&records=id=34&name=Test Name&email=test%40email.com&message=test&callback=Ext.data.JsonP.callback2
Thanks.
-
Best Answer Posted by mitchellsimoens
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.
-
10 Nov 2011 2:29 PM #2Sencha - Services Team
- Join Date
- May 2007
- Location
- Munich (Germany)
- Posts
- 2,292
- Vote Rating
- 6
- Answers
- 57
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
-
10 Nov 2011 4:45 PM #3
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
-
11 Nov 2011 7:05 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3107
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.


Reply With Quote