title: JSON parse data in javascript from php
body: <p>I'm trying to retrieve data in a javascript file from a php file using json.</p>
  
  <pre><code>$items = array(); 
  while($r = mysql_fetch_array($result)) { 
      $rows = array( 
          "id_locale" =&gt; $r['id_locale'], 
          "latitudine" =&gt; $r['lat'], 
          "longitudine" =&gt; $r['lng'] 
      ); 
      array_push($items, array("item" =&gt; $rows)); 
  } 
  ECHO json_encode($items);
  </code></pre>
  
  <p>and in the javascript file I try to recover the data using an ajax call:</p>
  
  <pre><code>$.ajax({
      type:"POST",
      url:"Locali.php",
      success:function(data){
          alert("1");
          //var obj = jQuery.parseJSON(idata);
          var json = JSON.parse(data);
          alert("2");
          for (var i=0; i&lt;json.length; i++) {
              point = new google.maps.LatLng(json[i].item.latitudine,json[i].item.longitudine);
              alert(point);
          }
      }
  })
  </code></pre>
  
  <p>The first alert is printed, the latter does not, it gives me error: Unexpected token &lt;.... but I do not understand what it is.</p>
  
  <p>Anyone have any idea where am I wrong?</p>
  
  <p>I also tried to recover the data with jquery but with no positive results.</p>