How do I create an associative array (or some comparable alternative) in jQuery and send this array via ajax to a php page so that I can use php to process it?
Something like that...
// jQuery if($something == true) { data[alt] = $(this).attr('alt'); data[src] = $(this).attr('src'); else if ($something == "something else") { data[html] = $(this).html(); }
Then send this array using the .ajax () function
// jQuery $.ajax({ data: /* somehow send my array here */, type: 'POST', url: myUrl, complete: function(){ // I'll do something cool here } });
Finally, parse this data with php ...
I worked a bit on this issue and read that you cannot create an associative array with javascript, so I'm really looking for an alternative. Thanks in advance.
source share