我發布了所有顯示數據后端但前面沒有顯示數據的圖像。我的代碼不起作用。我的代碼獲取數據并在控制臺和瀏覽器網絡中顯示數據,但沒有在像谷歌這樣的文本框下顯示建議我必須檢查所有事情但沒有得到一個想法我不明白這個。 <!DOCTYPE html> <html> <head> <title>Webslesson Tutorial | Autocomplete Textbox using Bootstrap Typehead with Ajax PHP</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> </head> <body> <br /><br /> <div class="container" style="width:600px;"> <h2 align="center">Autocomplete Textbox using Bootstrap Typeahead with Ajax PHP</h2> <br /><br /> <label>Search Country</label> <input type="text" name="country" id="country" class="form-control input-lg" autocomplete="off" placeholder="Type Country Name" /> </div> </body> </html> <script> $(document).ready(function() { $('#country').typeahead({ source: function(query, result) { $.ajax({ url: "autoselect_jquery2.php", // send request to a separate file method: "POST", data: { query: query }, dataType: "json", success: function(data) { result($.map(data, function(item) { return item; })); } }) } }); }); </script> //autoselect_jquery2.php <?php //Assume this line is correct and that you have a database.php file containing your log in credientials include 'database.php'; //If Statement says - run this next piece of code if $_POST['query'] is set to something if (isset($_POST['query']))
- 1 回答
- 0 關注
- 165 瀏覽
添加回答
舉報
0/150
提交
取消