简体   繁体   中英

ajax call(?) and jQuery autocomplete don't work

I have a problem with jQuery autocomplete. I have a header which a call in every page. the header contains these

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js">    </script>

Then in some pages I have a div in which I call different php pages with ajax. In one of them I want to set autocomplete with a mysql query(the function calls another page autocomplete.php) but it doesnt work. Do I need to include the jQuery path again? Could you give me an example how to do this?

The page I call

echo "<br/><h2 style=\"font-family:verdana;color:#00205e;\">Add new procedure</h2><br><br>";
echo "<form method=\"post\" name=\"newprocedure\" class=\"form\" action=\"user.php?uid=$id\" enctype=\"multipart/form-data\">";
echo <<< B
<p style="font-family:Verdana;color:#00205e;margin-left:-8px;">*<b>Name:</b><input type=\"text\" name="add_proc_name"/></p>
<p style="margin-left:-67px;font-family:Verdana;color:#00205e;"><b>Year:</b><input type="text" size="5" name="add_proc_year"/></p>
<p style="margin-right:-60px;font-family:Verdana;color:#00205e;"><b>File:</b><input type="file" name="add_proc_file" size="5" style="border:1px solid gray;width:170px;"/></p>  
<br><p style="margin-right:-110px;font-family:Verdana;color:#00205e;">&nbsp;<b>Description</b><br/><br/><textarea type="text" cols="25"  rows="5" name="add_proc_desc" >$proced[comments]</textarea></p>
<input type="hidden" name="hiddenid2"/>
<button type="submit">Add</button></form>
B;

The page jQuery calls from the above page

<?php

$q = strtolower($_GET["q"]);
if (!$q) return;
$sql="SELECT DISTINCT name as name from procedure_names where name LIKE 'q%' LIMIT 10";
open();
$result=mysql_real_escape_string(mysql_query($sql));
close();

while($rs = mysql_fetch_array($result)) {
    $proc = $rs['name'];
    echo "$proc\n";
}
 ?>

I will not include the jquery request as I have changed it many times and now I need time to make it again

Thank you


I can not even call alerts with jQuery on these pages. I really don't know what is wrong.

I noticed that jQ scripts (as hide(), click() etc) work only in header.php where I have called the jQuery sources. If I call them again in every page it doesnt work either :S

Any1 has any idea?

Did you add the Javascript to convert the text box to an autocomplete? http://docs.jquery.com/Plugins/autocomplete

eg $("#idofformelement").autocomplete('autocomplete.php')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM