Avatar of gplana
gplana
Flag for Spain asked on

How to send a javascript associative array by Ajax

Hi.

I have an associative array (an object with properties, implemented by an array object) which I would like to send by AJAX using jquery.

I have this sniped of code:

	var params = {
			'assoc_array': assoc_array,
			'another_param': 'blah blah',
		 };

	$.ajax({
		url: "my_url.php",
		data: params,
		type: 'post',
      });

Open in new window


the array is declared and filled this way:
var assoc_array = new Array(); 

function add_element(name,value){
   assoc_array[name]=value;
}

Open in new window


I can see on firebug that only the other parameter is send by post, but not the assoc_array parameter. Why?

Thanks.
JavaScriptAJAXjQuery

Avatar of undefined
Last Comment
gplana

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
gplana

ASKER
Excellent. It works!

Thank you very much.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy