function searchFilm(query){
$.get("search.php", {search: query}, function(data) {$("#replace_film").replaceWith(data);});
}
search.php页面有一些像这样的代码:
$link = mysql_connect("host","user","pass");
mysql_select_db("film",$link);
$search = $_GET['search'];
$query = mysql_query("SELECT * FROM film WHERE titolo LIKE '%$search%' ORDER BY id DESC",$link) or die("Errore");
echo "some information about film... (html code)";
mysql_close($link);
它工作得很好,但实际上有一点问题,在文本中有一些像这样的字符àòèù它会返回这个字符:
然后我在输入文本上使用onkeyup调用函数searchFilm。