0

I am trying to submit a form with ajax and also send a multidimensional array with the POST info which contains the email addresses to send to. I can't get this working. It doesn't seem to send the array, it just sends the words 'Array' (from what I can see in Chrome inspector):

//$results is the result of mysql query - multidimensional array
var email_array = "<?php echo json_encode($results); ?>"
$.ajax({  
        type: "POST",  
        url: "php/sendmail_client.php", 
        data: $("#send_mail_form").serialize() + "&email_array=" + email_array,
        dataType: "json",

New to jQuery here....

cantaffordavan
  • 1,427
  • 4
  • 24
  • 44
  • 1
    I'm just learning ajax myself. This question is similar to, but not duplicate of, [PHP json_encode() in while loop](http://stackoverflow.com/questions/6963243/php-json-encode-in-while-loop). See also [How do I properly use PHP to encode MySQL object into JSON?](http://stackoverflow.com/questions/11892699/how-do-i-properly-use-php-to-encode-mysql-object-into-json). Looks like you need to call `fetch_assoc()` on `$results`, to get the Array contents. – Mogsdad Jan 19 '13 at 01:16
  • See this: http://stackoverflow.com/questions/383631/json-encode-mysql-results – jtheman Jan 19 '13 at 01:22

0 Answers0