title: How do I create an associate array in jquery and send it via ajax to get parsed with php?
body: <p>How would I make an associative array (or some comparable alternative) in jQuery AND send that array via ajax to a php page so that I can use php to handle it?</p>
  
  <p>Something like this...</p>
  
  <pre><code>// jQuery
  
  if($something == true) {
      data[alt] = $(this).attr('alt');
      data[src] = $(this).attr('src');
  else if ($something == "something else") {
      data[html] = $(this).html();
  }
  </code></pre>
  
  <p>Then, send this array using the .ajax() function</p>
  
  <pre><code>// jQuery
  
  $.ajax({
      data: /* somehow send my array here */,
      type: 'POST',
      url: myUrl,
      complete: function(){
          // I'll do something cool here
      }
  });
  </code></pre>
  
  <p>Finally, parse this data with php...</p>
  
  <pre><code>// php
  
  &lt;img alt="&lt;?PHP echo $_POST['alt']; ?&gt;" src="&lt;?PHP echo $_POST['src']; ?&gt;" /&gt;
  </code></pre>
  
  <p>I've done a little googling on the subject and have read that you cannot make an associative array with javascript so I'm really just looking for some alternative. Thanks in advance.</p>