title: jquery ui autocomplete and php json string
body: <p>I'm using php to fetch the data from mysql database and then use that data on the jquery ui autocomplete. But it seems like the JSON that is returned doesn't match what jquery ui needs.
  The JSON returned looks something like this:</p>
  
  <pre><code>["dyes miran famint","annie ferrer mendrez","annie ferrer mendrez","anton setra masgre","anton setra masgre","jeniffer hades cruz","jeniffer hades cruz","alvin louie urbano maranon","alvin louie urbano maranon","francisza jerrielleza bullonza","blaze br tags anchor"]
  </code></pre>
  
  <p>I even used jQuery.parseJSON on it.</p>
  
  <p>And here's what I did on the php file:</p>
  
  <pre><code>$class_code = $_POST['class_code'];
  
  $student_list = array();
  $students = mysql_query("SELECT accounts.id, fname, mname, lname, classcode
                          FROM account_details
                          LEFT JOIN accounts ON account_details.id = accounts.id
                          LEFT JOIN class_rooster ON accounts.id = class_rooster.id
                          WHERE accounts.status = 1 AND accounts.type='student'
                          AND (class_rooster.id  IS NULL OR classcode !='$class_code')");
  $students_num = mysql_num_rows($students);
  if($students_num &gt; 0){
      while($row = mysql_fetch_assoc($students)){
  
          $student_list[] = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
  
      }
      echo json_encode($student_list);
  </code></pre>
  
  <p>Here's the error that I'm getting:</p>
  
  <pre><code>Uncaught TypeError: Property 'source' of object #&lt;Object&gt; is not a function
  </code></pre>
  
  <p>Here's the JavaScript:</p>
  
  <pre><code>function get_students(){
          var class_code = $('#current_classes').val();
          $.post('student_list.php', {'class_code' : class_code},
              function(data){
  
                  return data;
              }
          );
      }
  
  
      $("#student_name").live('click', function(){
  
          $("#student_name").autocomplete({
              source:  get_students()
          });
      });
  </code></pre>