Possible Duplicate:
Passing JavaScript Array To PHP Through JQuery $.ajax
I'm trying to pass some variables gathered from n dynamically generated inputs to php with ajax.
<input type="text" class="big" id="service" name="service[]" maxlenght="100"/>
This is the dynamically generated input(there could be 1 or 100). Now, if I submit them without ajax it gives me an array in php by simply doing
$services = $_POST['service'];
But what if I want to do it with ajax without refreshing the page?
var action = $("form_act").attr('action');
var form_data = {
service: $("#service").val(),
ajax_request: 1
};
$.ajax({
type: "POST",
url: action,
data: form_data,
dataType: "json",
success: function (response) {
if (response.error == 'none')
$("#form_content").slideToggle('slow', function () {
$('#form_content').load('includes/db_setup_form.php');
$("#form_content").delay(500).slideToggle('slow');
});
else {
$("#ajax_response").html("<p>" + response.msg + "</p>");
}
}
});
It only sends the first service variable and not a complete array with the others(if there are) variables. Any suggestions?