-
13 Dec 2011 1:37 PM #1
Answered: Can't get ExtJS REST proxy to POST
Answered: Can't get ExtJS REST proxy to POST
I'm using this ExtJS REST proxy to get and post data to my REST back end
When I do a print_r on the PHP receiving end it looks like $_POST is emptyHTML Code:this.eventStore =Ext.create('Extensible.calendar.data.EventStore',{ autoLoad:true, proxy:{ type:'rest', url:'http://www.notmyrealdomain/testapp/index.php/api/events', format:'json', noCache:false, reader:{ type:'json', root:'data' }, writer:{ type:'json', nameProperty:'mapping' } } }
HTML Code:print_r($_POST) array()
When I look at Firebug I see that my API page does have JSON being posted to it but the response is just the empty $_POST array.I have checked my config.php BASE_URL and it is my full url http://www.notmyrealdomain.com/testappand I'm pretty sure my proxy above is posting to that url, it's not returning 404 and it doesn't look like it would be cross domain or anything.Does anyone have any suggestions? I've been looking at this for 8 hours now and need some new eyes.
-
Best Answer Posted by dogomatic
It's in the post body as json, not in the post query args.
http://stackoverflow.com/questions/6...703326#6703326
use:
also, don't forget to use the code tag (like html with square brackets) when posting code.Code:$form_data = json_decode(file_get_contents('php://input'));
-
14 Dec 2011 1:14 AM #2
It's in the post body as json, not in the post query args.
http://stackoverflow.com/questions/6...703326#6703326
use:
also, don't forget to use the code tag (like html with square brackets) when posting code.Code:$form_data = json_decode(file_get_contents('php://input'));
-
14 Dec 2011 1:46 AM #3Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
Are you sure your proxy is posting and not getting?
In the case it is getting. Set actionMethods on your proxy
like
in the default setting read is a GET.Code:actionMethods: {create: "POST", read: "POST", update: "PUT", destroy: "DELETE"}
-
14 Dec 2011 8:24 AM #4
-
14 Dec 2011 5:30 PM #5
Nice!
It is normal if you're posting json. Query args have to be of the form key=value, so how would you represent a json object with nested objects and arrays? It's hacky but possible to do with some sort of dot notation, but much more sensible to use the post body.
I don't know if it's in the docs, but I've seen this question asked a few times.
Maybe make a post in the doc bugs thread:
http://www.sencha.com/forum/showthre...n-Content-Bugs
Also, it's partly php's fault for making the post body so obscure.
-
15 Nov 2012 5:30 AM #6


Reply With Quote