title: jquery ajax sortable pass data in object as key value after serialize
body: <p>I am using jquery ui sortable to reorder a list via php, I get the ids like so:</p>
  
  <pre><code>var ids = $('#sort1').sortable('serialize');
  </code></pre>
  
  <p>It works fine when on <code>update</code> in the ajax call I pass the <code>data</code> in the ajax call like so:</p>
  
  <pre><code>data: ids
  </code></pre>
  
  <p>And then catch in inside my php script like so (notice singular id):</p>
  
  <pre><code>$getids = $_POST['id'];
  </code></pre>
  
  <p>All that works fine, however I want to pass the data inside an object because there are other things I want to pass along as well, but it does not seem to be working.</p>
  
  <p>I tried:</p>
  
  <pre><code>data: {
      id: ids
  },
  </code></pre>
  
  <p>then I get this php error:</p>
  
  <pre><code> Warning: Invalid argument supplied for foreach() in C:\wamp\www\sortable\sort.php on line 8
  </code></pre>
  
  <p>And I also tried changing <code>$getids = $_POST['id'];</code> to <code>$getids = $_POST['ids'];</code> but then I get unidentifed index and also invalid argument error.</p>
  
  <p>How can I pass the <code>ids</code> inside an object as key value pair?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>the foreach code</p>
  
  <pre><code>$count = 1;
  foreach ($getids as $key =&gt; $id) {
      $q = "UPDATE titles SET sorting='$count', parent_id='1' WHERE id='$id'";
      $r = mysqli_query($dbc, $q);
  
      if ($r) {
          echo 'done &lt;br&gt;';
      } else {
          echo 'problem &lt;br&gt;' . mysqli_error($dbc);
      }
      $count++;
  }
  </code></pre>