I want to send some form data with ajax.Imagine that the some fields of the form are filled from previous times and the user adds a new one…take a look at this fiddle.
Click edit and then the plus icon to understand what I am talking about.
The newly added field has name attribute value of this form form[4][service]
That will help me grab only the value of this field and ignore the others(filled from previous times) in the server side…take a look at the code…line 75
The questions is this…If I enclose the data in an object like this:
data: {form:$( "#serv" ).serialize(),}
How I will be able to access in the server again the fields with name attribute value like the one above?
Currently I grab the data with this much familiar code:
no…it does not work…I get the familiar “illegal string offset” message and even if it did there is no point in targeting only one newly added field but all that the user adds to the form.
debugging #1: check var_dump($_POST['form']) to see what PHP receives.
debugging #1.5: check the browser’s network tab for the outgoing post.
debugging #2: check what $( "#serv" ).serialize() actually returns.
Well, since we cannot see what $( "#serv" ).serialize() would return, there is not a lot we can actually do. that’s why you should check the request, since it contains that information.