POST/PUT Form Data format...
POST/PUT Form Data format...
I have an issue. I'm using the editor to add and edit data from tables. When I go to post or put the data to my server, DataTables changes the Names of the inputs. For example, I may have an input called 'FirstName' but when the data posts, it shows up as 'data[FirstName]=Bryan'. It's placing my post data name in brackets and adding the word data to the beginning of each name. You can even see this functionality on the examples on this site. Is there a way to keep the name intact such as 'FirstName=Bryan'? Hopefully, I'm asking my question correctly. Thanks!
Answers
Hi,
The Editor manual describes how the client-side communicates with the server. The
data[]
syntax indicates that the data is being sent as an object - but many server-side environments will automatically decode into an object, but presumably not the one you are using!Either you could decode it, or use
ajax.data
to remap the data that Editor would send into something that you want - i.e. flatten thedata
object to the top level.Regards,
Allan
Thanks for the response, allan. I think I'm really close to figuring this out. Here's what I have so far...
When I do this, I get both the original data object and the new object. This works, but why is it sending both objects? The manual says that it should replace the original object. Here's what the string looks like...
The manual is correct, and I think the implementation might be wrong. I'm away from my main computer at the moment, but I'll check this when I get back.
In the mean time, what you could do is:
So the original object will be used, but with the
data
property removed.Allan
I've just checked this and it appears to be working as expected for me. If I do:
then only
a = 1
is sent to the server.Could you link me to an example page that shows the issue please? Also might be worth checking you are using the current release (1.3.3) if you aren't already.
Allan