我想在数据库中显示关键更改的数据,他们将输入地名,它将使用getPlaces.php检查数据库并在showlist div上输出。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$('form')[0].reset();
$("form").attr("autocomplete", "off");
//$("#place").focus();
$('#place').on('keyup', function(e){
var min_length = 1; // min caracters to display the autocomplete
var keyword = $('#place').val();
if (keyword.lengtd>= min_length) {
$.post("getPlaces.php", $('form').serialize(), function(response) {
$('#showlist').html(response);
$('#showlist').show();
});
}
});
});//]]>
</script>
</head>
<body id="up">
<div id="form"><form><input type="text" id="place" name="place" placeholder="write area name .." /></form></div>
<div id="showlist">
</div>
</body>
</html>
php文件工作正常。但我没有得到任何内容!
答案 0 :(得分:0)
你拼错了keyword.lengtd
。它应该是keyword.length
。
答案 1 :(得分:0)
使用此脚本代码
<script type='text/javascript'>
$(window).load(function(){
$('form')[0].reset();
$("form").attr("autocomplete", "off");
//$("#place").focus();
$('#place').on('keyup', function(e){
var min_length = 1; // min caracters to display the autocomplete
var keyword = $('#place').val();
if (keyword.length >= min_length) {
$.post("getPlaces.php", $('form').serialize(), function(response) {
$('#showlist').html(response);
$('#showlist').show();
});
}
});
});
</script>