Why does nothing happen with this code? Where is the mistake? Simple working example (jquery autocomplete and jsonp) + php

<!doctype html> <html> <head> <title>ы</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript" src="jquery.autocomplete.js"></script> <script> $(document).ready(function(){ $("#search").keyup(function(){ $("#search").autocomplete({ source: function( request, response ) { alert(1) }, delay:10, minChars:1, maxItemsToShow:10 }); }); }); </script> </head> <body> <form action=""><input type="search" id="search"> <input type="submit"></form> </body> </html> 
  • Is there silence in the console? Onclick and the like work? - Sh4dow
  • <script type = "text / javascript" src = "jquery.autocomplete.js"> </ script> Do you have jquery.autocomplete.js script in the same folder as the html page? - Mobyman
  • 2
    ui need to connect - Vfvtnjd

2 answers 2

autocomplete it is a plugin, or as another widget that will not work without jQuery and jQueryUI core.

See which libraries should be connected to function properly.

    I do not understand the principle of your script initialization. Why do you hang up on $ ("# search"). Keyup ()? The person will type a letter, after which the plug-in will be initialized, which will wait for the letter to be entered, and will the letter input be re-initialize the plugin, respectively?

     $(document).ready(function(){ $("#search").autocomplete({ ... }); }); 

    Plus, specify which Autocomplit you are trying to use. There is a plugin that was originally created. There is a widget (they took a plugin and implemented it in jquery UI with changing call parameters). Depending on what kind of autocomplex you have, they need to be connected and initialized in different ways.