title: JQuery + Json - first steps with an example
body: <p>I need (recently) to get an array from the server after an ajax call created by jquery. I know that i can do it using JSON. But i don't know how to implement it with JQuery (im new with JSON). I try to search in internet some example, but i didnt find it.</p>
  
  <p>This is the code :</p>
  
  <pre><code>// js-jquery function
  function changeSponsor() {
      $.ajax({
          type: 'POST',
          cache: false,
          url: './auth/ajax.php',
          data: 'id=changespon',
          success: function(msg) {
              // here i need to manage the JSON object i think
          }
      });
      return false;
  }
  
  // php-server function
  if((isset($_POST['id'])) &amp;&amp; ($_POST['id']=="changespon")) {
      $linkspon[0]="my ";
      $linkspon[1]="name ";
      $linkspon[2]="is ";
      $linkspon[3]="marco!";
  
      echo $linkspon;
  }
  </code></pre>
  
  <p>in fact, i need to get the array $linkspon after the ajax call and manage it. How can do it? I hope this question is clear. Thanks</p>
  
  <p>EDIT</p>
  
  <p>ok. this is now my jquery function. I add the $.getJSON function, but i think in a wrong place :)</p>
  
  <pre><code>function changeSponsor() {
      $.ajax({
          type: 'POST',
          cache: false,
          url: './auth/ajax.php',
          data: 'id=changespon',
          dataType: 'json',
          success: function(data) {
              $.getJSON(url, function(data) { alert(data[0]) } ); 
          }       
      });
  
      return false;
  }
  </code></pre>