Welcome Guest, Not a member yet? Register   Sign In
How do you get request body data in controller?
#7

[eluser]SpudNik[/eluser]
[quote author="Aken" date="1329682589"]Is there a reason you're setting the content type to JSON? You shouldn't need to specify the content type unless wherever you are sending the data explicitly needs a JSON request. Just because your data is in JSON doesn't mean it's going to stay that way once it goes through the ajax call (it doesn't, btw). You should be able to remove that line, then use $this->input->post() like normal.

Also, the "dataType" parameter is specifying what format the RESPONSE will be in, so if you set that, make sure your response is in JSON and not something else, or your returned data might not work properly.[/quote]

Right. The client accepts "application/json". Thus the dataType:json. In terms of JQuery the data can be sent in the same format in which is set. This is done by using the processData:false switch. I just thought that CI had a wrapper object that basically did what I have above. This might be a feature of CI Rest Server. Thanks for the response. What I have works well enough.


Messages In This Thread
How do you get request body data in controller? - by El Forum - 02-18-2012, 03:05 PM
How do you get request body data in controller? - by El Forum - 02-18-2012, 04:46 PM
How do you get request body data in controller? - by El Forum - 02-18-2012, 07:16 PM
How do you get request body data in controller? - by El Forum - 02-18-2012, 08:56 PM
How do you get request body data in controller? - by El Forum - 02-19-2012, 01:05 PM
How do you get request body data in controller? - by El Forum - 02-19-2012, 01:16 PM
How do you get request body data in controller? - by El Forum - 02-19-2012, 04:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB