I’m a newbie so be kind 🙂
In Javascript, how do I add to a variable the current entry from an array? See my code below.
<?php
$array = mysql_query(SELECT column1 FROM table1 WHERE column2='$entry');
//this returns several entries
<script>
var array=<?=json_encode($array)?>; // the
var data={mouse:mickey, rabbit:roger};
$.each(array, function(){
$.post('dostuff.php',data+','+{array[this]}); // <-- not sure
});
</script>
?>
My question is about the data sent in the “post” jquery command. how do I add the current database entry and send it as part of the data sent in the ajax request. I wrote it roughly, but I’m confident it isn’t right the way I wrote it here.
Thanks!
You can add properties directly to your data object. Also note that the supplied function for each can take an index, and a value parameter.