October 21, 201114 yr I have a problem with submitting an array of data via ajax submit. If I disable the ajax ... my php handling seems to work perfect but with the ajax added it seems to be conflicting with my foreach loop within my php. My form code is: <tr><td><textarea class="text" name="event_summary[]" rows="1" cols="1"></textarea></td></tr> <tr><td><textarea class="text" name="event_summary[]" rows="1" cols="1"></textarea></td></tr> <tr><td><textarea class="text" name="event_summary[]" rows="1" cols="1"></textarea></td></tr> <tr><td><textarea class="text" name="event_summary[]" rows="1" cols="1"></textarea></td></tr> <tr><td><textarea class="text" name="event_summary[]" rows="1" cols="1"></textarea></td></tr> This code for my php is: foreach ($_POST["event_summary"] as $single_summary) { // check the value for empty line $single_summary = trim($single_summary); if (!empty($single_summary)) { $insertEventSummary = mysql_query("INSERT INTO EVENT_SUMMARY (PatientID, Description) VALUES ('$patientID', '$single_summary')"); } } And the code being used to create the array via jquery is: var event_summary = new Array(); $("textarea[name^='event_summary[]']").each(function() {event_summary.push($(this).val());}); If anyone could help me shed some light into exactly what the problem is, it would be very appreciated. Thanks
Create an account or sign in to comment