I am trying to post a javascript array to a php page. The array has to be associative. My structure looks like this:
<input id="test" value="1" class="settings" />
<input id="test1" value="2" class="settings" />
When I create the array it is:
var myArray = new Array();
$(".setttings").each(function(){
myArray[$(this).attr("id")] = $(this).val();
});
Now when I post that data I am just doing:
$.ajax({
type: "POST",
url: 'post.php",
data: "settings="+myArray,
});
The problem is that in firebug if I look at the post for settings it is empty. I need the array passed like this because I am going to take each of those settings into php and serialize them and insert them into a field in a database. That way I can pull the settings back out and unserialize to repopulate those fields. Any ideas how I can do this?