Monday 15 February 2010

jquery autocomplete sends empty get value to php -


I am very new to jquery n javascript. I am trying to create an autocomplete feature I am using a sample code from a diff page to do this but the 'term' passes through the PHP page is empty so it does not work automatically. I can not understand why anyone looks? I did not change the label, but I'm just trying to see if it works or not. The problem is with the php page, the request 'word' is empty.

  & lt; Head & gt; & Lt; Link href = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel = "stylesheet" type = "text / css" /> & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Function () {$ ( "#txtLanguage"). Autocomplete ({source: "source.php", minLength: 1 // auto many characters you type to complete the display}};}); & Lt; / script & gt; & Lt; / head & gt; & LT; Body & gt; & Lt; label = "language" & gt; language: & lt; / label & gt; & Lt; input id = "TxtLanguage" class = "txtLanguage" / & gt; & Lt; / div & gt; & Lt; / body & gt; & Lt; / html & gt; & Lt ;? Php include 'dbconnect.php'; $ Q = $ _ rEQUEST [ 'word']; echo $ q; $ Return = array (); $ Stat = "select emails from users where email is email as $ q '; $ Query = sqlsrv_query ($ conn, $ Stat); while $ line = sqlsrv_fetch_array ($ query, SQLSRV_FETCH_ASSOC)) {arr Ay_push ($ return, array ('label' = & gt; $ row ['email'], 'value' = & gt; $ row ['email']));} echo (json_encode ($ return)); & Gt;    

I think you need it: < Pre> $ stat = "select` email` to` user 'where' $ q% 'like' email ';

You forgot for the% symbol and the email = '$ q'

No comments:

Post a Comment