Skip to main content
Corrected Spelling, grammar, formatting, added php tag as it seems relevant
Source Link
Heretic Monkey
  • 12.1k
  • 7
  • 62
  • 133

Send Associativeassociative array through ajax

I was trying to send an associative array of warnings and when a button is clicked it. It will pass id and type of warning and trigger collect function which stores them in tointo the array as key value pairs then. Then I want to send it to another page the. The problem is if it is simple array it will work when I call $_POST ['warn']; but if I change it to associative an associative array I will get error msg saying that warn is not defined this. This is my JS code -:

var warnings = [];
function collect(id,type){ warnings [id]  = type;}
 
$('#but1').click (function (){
  $.post ("url", {warn: warnings}function(r){alert (r);});
});

isIs there a way to send the associative array as key value pairs using AJAX to my php page and get the array using $_POST $_POST?

thanx,

Send Associative array through ajax

I was trying to send an associative array of warnings and when button is clicked it will pass id and type of warning and trigger collect function which stores them in to the array as key value pairs then I want to send it to another page the problem is if it is simple array it will work when I call $_POST ['warn']; but if I change it to associative array I will get error msg saying that warn is not defined this is my JS code -

var warnings = [];
function collect(id,type){ warnings [id]  = type;}
 
$('#but1').click (function (){
$.post ("url", {warn: warnings}function(r){alert (r);});
});

is there a way to send the associative array as key value pairs using AJAX to my php page and get the array using $_POST ?

thanx,

Send associative array through ajax

I was trying to send an associative array of warnings when a button is clicked. It will pass id and type of warning and trigger collect function which stores them into the array as key value pairs. Then I want to send it to another page. The problem is if it is simple array it will work when I call $_POST ['warn']; but if I change it to an associative array I will get error msg saying that warn is not defined. This is my JS code:

var warnings = [];
function collect(id,type){ warnings [id]  = type;}
$('#but1').click (function (){
  $.post ("url", {warn: warnings}function(r){alert (r);});
});

Is there a way to send the associative array as key value pairs using AJAX to my php page and get the array using $_POST?

send assotiative Send Associative array through ajax

iI was trying to send an assotiativeassociative array of warnings and when button is clicked it will pass id and type of warning and trigertrigger collect function which stores them in to the array as key value pairs then iI want to send it to another page the problem is if it is simple array it will work when iI call $_POST ['warn']; but if iI change it to assotiativeassociative array iI will get error msg saying that warn is not defined this is my JS code -

var warnings = [];
function collect(id,type){ warnings [id]  = type;}

$('#but1').click (function (){
$.post ("url", {warn: warnings}function(r){alert (r);});
});

is there a way to send the assotiativeassociative array as key value pairs using ayaxAJAX to my php page and get the array using $_POST ?

thanx,

send assotiative array through ajax

i was trying to send an assotiative array of warnings and when button is clicked it will pass id and type of warning and triger collect function which stores them in to the array as key value pairs then i want to send it to another page the problem is if it is simple array it will work when i call $_POST ['warn']; but if i change it to assotiative array i will get error msg saying that warn is not defined this is my JS code -

var warnings = [];
function collect(id,type){ warnings [id]  = type;}

$('#but1').click (function (){
$.post ("url", {warn: warnings}function(r){alert (r);});
});

is there a way to send the assotiative array as key value pairs using ayax to my php page and get the array using $_POST ?

thanx,

Send Associative array through ajax

I was trying to send an associative array of warnings and when button is clicked it will pass id and type of warning and trigger collect function which stores them in to the array as key value pairs then I want to send it to another page the problem is if it is simple array it will work when I call $_POST ['warn']; but if I change it to associative array I will get error msg saying that warn is not defined this is my JS code -

var warnings = [];
function collect(id,type){ warnings [id]  = type;}

$('#but1').click (function (){
$.post ("url", {warn: warnings}function(r){alert (r);});
});

is there a way to send the associative array as key value pairs using AJAX to my php page and get the array using $_POST ?

thanx,

Source Link

send assotiative array through ajax

i was trying to send an assotiative array of warnings and when button is clicked it will pass id and type of warning and triger collect function which stores them in to the array as key value pairs then i want to send it to another page the problem is if it is simple array it will work when i call $_POST ['warn']; but if i change it to assotiative array i will get error msg saying that warn is not defined this is my JS code -

var warnings = [];
function collect(id,type){ warnings [id]  = type;}

$('#but1').click (function (){
$.post ("url", {warn: warnings}function(r){alert (r);});
});

is there a way to send the assotiative array as key value pairs using ayax to my php page and get the array using $_POST ?

thanx,