title: How to convert the values in an array to strings and send to php?
body: <p>I have a javascript file here.What it does is,when a user selects seats accordings to his preference in a theater layout,the selected seats are stored in an array named "seat".This code works fine until function where the selected seats are shown in a window alert.But from there onwards,the code doesn't seem to do anything.</p>
  
  <p>After the above window alert, I've tried to serialize the above array and send it to the "confirm.php" file.But it does not show anything when echoed the seats.</p>
  
  <p>Here is the js code.</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script type="text/javascript"&gt;
  
      $(function () {
          var settings = {
              rows: 6,
              cols: 15,
              rowCssPrefix: 'row-',
              colCssPrefix: 'col-',
              seatWidth: 80,
              seatHeight: 80,
              seatCss: 'seat',
              selectedSeatCss: 'selectedSeat',
              selectingSeatCss: 'selectingSeat'
          };
  
          var init = function (reservedSeat) {
              var seat = [], seatNo, className;
              for (i = 0; i &lt; settings.rows; i++) {
                  for (j = 0; j &lt; settings.cols; j++) {
                      seatNo = (i + j * settings.rows + 1);
                      className = settings.seatCss + ' ' + settings.rowCssPrefix + i.toString() + ' ' + settings.colCssPrefix + j.toString();
                      if ($.isArray(reservedSeat) &amp;&amp; $.inArray(seatNo, reservedSeat) != -1) {
                          className += ' ' + settings.selectedSeatCss;
                      }
                      seat.push('&lt;li class="' + className + '"' +
                              'style="top:' + (i * settings.seatHeight).toString() + 'px;left:' + (j * settings.seatWidth).toString() + 'px"&gt;' +
                              '&lt;a title="' + seatNo + '"&gt;' + seatNo + '&lt;/a&gt;' +
                              '&lt;/li&gt;');
                  }
              }
              $('#place').html(seat.join(''));
          };
  
          var jArray = &lt;?= json_encode($seats) ?&gt;;
          init(jArray);
  
  
          $('.' + settings.seatCss).click(function () {
              if ($(this).hasClass(settings.selectedSeatCss)) {
                  alert('This seat is already reserved!');
              } else {
                  $(this).toggleClass(settings.selectingSeatCss);
              }
          });
  
  
          $('#btnShowNew').click(function () {
              var seat = [], item;
              $.each($('#place li.' + settings.selectingSeatCss + ' a'), function (index, value) {
                  item = $(this).attr('title');
                  seat.push(item);
              });
              window.alert(seat);
          });
  
          $('#btnsubmit').click(function () {
              var seat = [], item;
              $.each($('#place li.' + settings.selectingSeatCss + ' a'), function (index, value) {
                  item = $(this).attr('title');
                  seat.push(item);
                  var seatar = JSON.stringify(seat);
                  $.ajax({
                      method: "POST",
                      url: "confirm.php",
                      data: {data: seatar}
                  });
              });
          });
  
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Can somebody help me figure it out what's wrong in here?</p>