Error using json.stringify to send array to php

Error using json.stringify to send array to php

Now that I have my map function working properly, I need to send the array to php - here is my script

  1. <script type="text/javascript">
  2. $(function()
  3. {
  4.     $('#submitButton').click(function(){
  5.         var reservations = $("#main_table table input[name=name]:checked").map(function() {
  6.                 row = $(this).closest("tr");
  7.                 return { 
  8.                          recordid    : $(row).find('input[name=record_id]').val(),
  9.                          firstname   : $(row).find('input[name=firstname]').val(),
  10.                          lastname    : $(row).find('input[name=lastname]').val(),
  11.                          timeneeded  : $(row).find('input[name=timeneeded]').val(),
  12.                          dateneeded  : $(row).find('input[name=dateneeded]').val(),       
  13.                          pickup      : $(row).find('input[name=pickup]').val(),       
  14.                          dropoff     : $(row).find('input[name=dropoff]').val(),       
  15.                          drivername  : $(row).find('td:eq(7)').text()
  16.                         }
  17.             }).get();
  18.         console.log(reservations);
  19. infotosend = JSON.stringify(reservations);
  20.         $.ajax({
  21. type: "POST",
  22. contentType: "application/json",
  23. url: "create_assignments.php",
  24. data: {data : infotosend},
  25. dataType: 'json',
  26. cache: false,
  27. timeout: 100000,
  28. success: function (data) {

  29. console.log("SUCCESS : ", data);

  30. },
  31. error: function (e) {

  32. console.log("ERROR : ", e);

  33. }
  34. });
  35.     });
  36. });

  37. </script>

  38. I built the .ajax part off of suggestions I found here on the forum. It's firing an error, because the php program reports ' Undefined index: infotosend' so I have something malformed, I've tried using several variations on the Data line, but I still get the same error.