title: ajax in wordpress not calling php function
body: <p>wonder if anyone can help; I'm trying to implement some ajax through jquery onto a form in a wordpress template.</p>
  
  <p>The jquery is working, and the I can log a console message in the sucess: section, but the data is 0, when it should be calling the php function (at the moment on the same page, and I can call this directly)</p>
  
  <p>so I guess the jquery is working, the admin-ajax is being called, its just the php function is not being called. Any ideas what I could be doing wrong ? I don't fully understand hooks, so perhaps that is an issue - that I need to hook something in somewhere?</p>
  
  <p>jquery (domain would replace comments)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      jQuery(function ($) {
          $( "#movies" ).autocomplete({
                  minLength:2,
                  delay:500,
                  source: function( request, response ) {
                      $.ajax({
                          type: 'POST',
                          url: "http://&lt;!--domain here --&gt;/wp-admin/admin-ajax.php",
                          dataType: 'json',
                          data: {
                              action: 'getMoviesForCode',
                              searchString: $("#movies").val()
                          },
                          success: function( data ) {
                              response(data);
                              console.log('jjj'+data);
                          }
                      });
                  }           
          });
      });
      &lt;/script&gt; 
  </code></pre>
  
  <p>php function (on same page)</p>
  
  <pre><code>&lt;?php
  
      function getMoviesForCode(){
  echo "
          &lt;script type=\"text/javascript\"&gt;
          alert(\"hh\");
          &lt;/script&gt;
      ";
     $searchString = $_POST['searchString'];
     $results = va_getMoviesForCode($searchString);  
    $results = json_encode($results);
    die($results);
  }
   ?&gt;
  </code></pre>
  
  <p>Thanks,</p>