title: jquery autocomplete using ajax
body: <p>I have got this code</p>
  
  <pre><code>&lt;!doctype html&gt;
  
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /&gt;
    &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
    &lt;script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" href="/resources/demos/style.css" /&gt;
    &lt;style&gt;
    .ui-autocomplete-loading {
      background: white url('images/ajax-loader.gif') right center no-repeat;
    }
    #city { width: 25em; }
    &lt;/style&gt;
    &lt;script&gt;
    $(function() {
      function log( message ) {
        $( "&lt;div&gt;" ).text( message ).prependTo( "#log" );
        $( "#log" ).scrollTop( 0 );
      }
  
      $( "#city" ).autocomplete({
        source: function( request, response ) {
          $.ajax({
            url: "http://localhost/file.php",
            dataType: "jsonp",
            data: {
              featureClass: "P",
              style: "full",
              maxRows: 12,
              name_startsWith: request.term
            },
            success: function( data ) {
              response( $.map( data.geonames, function( item ) {
                return {
                  label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
                  value: item.name
                }
              }));
            }
          });
        },
        minLength: 2,
        select: function( event, ui ) {
          log( ui.item ?
            "Selected: " + ui.item.label :
            "Nothing selected, input was " + this.value);
        },
        open: function() {
          $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
        },
        close: function() {
          $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
        }
      });
    });
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div class="ui-widget"&gt;
    &lt;label for="city"&gt;&lt;/label&gt;
    &lt;input id="city" /&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP CODE for file.php</p>
  
  <pre><code>&lt;?php echo $_GET['name_startsWith']; ?&gt;
  </code></pre>
  
  <p>Now, i want to get the data here through ajax dynamically using database. Now when i runs this code, i dont get any response &amp; the image of ajax loader continuously gets displayed.</p>
  
  <p>How can i make it work ?</p>
  
  <p>Thanks</p>