title: How to unserialize a serialized array sent to the server using GET method with a jQuery Ajax call?
body: <p>I'm trying to deserialize an array from an URL I've sent from a JQuery Ajax call to a PHP script in the server.</p>
  <h2>What I have done</h2>
  <p>I've been sending variables with values to the server successfully with jQuery Ajax this way:</p>
  <pre><code>// A simple text from an HTML element:
  var price = $(&quot;#price option:selected&quot;).val();
  // Yet another simple text:
  var term1 = $('#term1').val();
  </code></pre>
  <p>Then I prepare the data to be sent via Ajax this way:</p>
  <pre><code>var data = 'price=' + price + '&amp;term1=' + term1;
  //if I alert it, I get this: price=priceString&amp;term1=termString
  </code></pre>
  <p>And send it with jQuery Ajax like this:</p>
  <pre><code>$.ajax({
          url: &quot;script.php&quot;,
          type: &quot;GET&quot;,
          data: data,
          cache: false,
          dataType:'html',
          success: function (html) {
              // Do something successful
          }
  });
  </code></pre>
  <p>Then I get it in the server this way:</p>
  <pre><code>$price = (isset($_GET['price'])) ? $_GET['price'] : null;
  $term1 = (isset($_GET['term1'])) ? $_GET['term1'] : null;
  </code></pre>
  <p>And I'm able to use my variables easily as I need. However, I need to do this with an array.</p>
  <h2>Main question</h2>
  <p>Reading a lot, I've managed to learn the professional way to send an array to the server: serialize it! I've learnt this way to do it with jQuery:</p>
  <pre><code>var array_selected = [];
  // This is used to get all options in a listbox, no problems here:
  $('#SelectIt option:not(:selected), #SelectIt option:selected').each(function() {
     array_selected.push({ name: $(this).val(), value: $(this).html().substring($(this).html().indexOf(' '))});
  });
  var array_serialized = jQuery.param(array_selected);
  // If I alert this I get my array serialized successfully with in the form of number=string:
  //Ex. 123=stringOne&amp;321=StringTwo
  </code></pre>
  <p>This seems to be right. I add this to the data as before:</p>
  <pre><code>var data = 'price=' + price + '&amp;' + array_selected + '&amp;term1=' + term1;
  //if I alert it, I get this: price=priceString&amp;term1=termString&amp;123=stringOne&amp;321=StringTwo
  </code></pre>
  <p>How do I reconstruct (unserialize) my array in the server? I've tried the same as before:</p>
  <pre><code>$array_serialized = (isset($_GET['array_serialized'])) ? $_GET['array_serialized'] : null;
  </code></pre>
  <p>with no success! Any ideas why? How can I get my serialized array passed this way in the server as another array which PHP can handle so I can use it?</p>
  <p>Or am I complicating my life myself needlessly? All I want is to send an array to the server.</p>