title: ajax to get value one result on php page
body: <p>This will return only one row how to simply pass that row to ajax call.
  below code passing data , but when i print it in loop it print unlimited times.</p>
  
  <p>AJAX::</p>
  
  <pre><code>$.ajax({
    type: "POST",
    url: 'userLoginCheckforRetrieve.php',
    data: {
    },
     success:function(data)   { 
     alert('outside loop is '+data);
   for(var i=0; i &lt; data.length ; i++){
      alert('loop date is '+data[i].name);
      }
  }
  });
  </code></pre>
  
  <p>PHP ::</p>
  
  <pre><code>$sel_query= "SELECT image_name FROM save_designs WHERE user_name='{$username}'";
      $sel_result = mysql_query($sel_query);
  
      $data = array();
      while($item = mysql_fetch_object($sel_result))
          {
              $data[] = array(
                  'name' =&gt; $item-&gt;image_name                
              );
          }
      echo json_encode($data);
  </code></pre>