Sending form data with AJAX...some details

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:

$_POST['form'];//accessing the fields in question

$_POST['form'][4]['service'] ?

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.

I am(was) in the process of examining all these but I still have not find a way to figure this out.

There is a problem with the fiddle, there is no ID named serv

I know that…the fiddle is just a demo…it does not work-no ajax requests are made from it.

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.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.