Hello All,
Sorry, I know this has been asked multiple times, but I have read all the other threads and still can't seem to get this to work properly.
I need to pass the following data as an array to a php page for a MySQL insert:
<form>
<input type="text" name="fruits[]" size="30" maxlength="50" />
<input type="text" name="fruits[]" size="30" maxlength="50" />
<input type="text" name="fruits[]" size="30" maxlength="50" />
<input type="text" name="fruits[]" size="30" maxlength="50" />
</form>
When I try the following I just get a list of strings that submits the first value as "fruits[]=Peach".
var fruits = $('input[name= fruits[]]').serialize();
ajax post data: 'fruits[]=' + fruits,
PHP code:
foreach ($_POST['fruits'] as $fruit){
//do MySQL insert
}
All array values after "fruits[]=Peach" are then submitted correctly as the value only.
Does anyone know what I am missing here, am I suppose to use serializeArray? I tried that and when I do I get no data passed.
Any help would be awesome, thank you!!!