How would I make an associative array (or some comparable alternative) in jQuery AND send that array via ajax to a php page so that I can use php to handle it?
Something like this...
// 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...
// php
<img alt="<?PHP echo $_POST['alt']; ?>" src="<?PHP echo $_POST['src']; ?>" />
I've done a little googling on the subject and have read that you cannot make an associative array with javascript so I'm really just looking for some alternative. Thanks in advance.