Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Possible Duplicate:
Passing JavaScript Array To PHP Through JQuery $.ajax 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?

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?

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?

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"<p>" + response.msg+"<msg + "</p>");

 }
 }
});

It only sends the first service variable and not a complete array with the others(if there are) variables. Any suggestions?

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?

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?

insert duplicate link
Source Link

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?

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?

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?

Post Closed as "exact duplicate" by Jeff Atwood
Loading
Source Link
g0dl3ss
  • 383
  • 1
  • 6
  • 19
Loading
default

AltStyle によって変換されたページ (->オリジナル) /