用JS和PHP在autocomplete上重新加载部分页面?
好吧,卡在这里。。。 我有一个自动完成框用JS和PHP在autocomplete上重新加载部分页面?,php,jquery,mysql,typeahead.js,Php,Jquery,Mysql,Typeahead.js,好吧,卡在这里。。。 我有一个自动完成框 <div id="sites"> <span></h4>Site Review</h4><input class="typeahead form-control" type="text" placeholder="Spot Check for..."></span> </div> 现在,如何在不使用iframe的情
<div id="sites">
<span></h4>Site Review</h4><input class="typeahead form-control" type="text" placeholder="Spot Check for..."></span>
</div>
现在,如何在不使用iframe的情况下使用get_site_attributes.php的内容重新加载该div
-提前感谢正如评论中所说,您必须使用ajax 在需要刷新DOM内容的任何位置调用方法ajaxCall 假设你有:
<h1 class='site_title'></h1>
正如在评论中所说的,您必须使用ajax 在需要刷新DOM内容的任何位置调用方法ajaxCall 假设你有:
<h1 class='site_title'></h1>
javascript和一些ajax。使用ajax从数据库获取信息,然后使用javascript或jQueryjavascript以及一些ajax更新div内容。使用ajax从数据库中获取信息,然后使用javascript或jQuery更新div内容
var ajaxCall = function(){
$.ajax({
url : 'get_site_attributes.php', #or relative path
type : 'GET',
dataType:'', #whatever get_site_attributes.php is returning: html/json/...
success : function(data) {
updateDatas(data);
},
error : function(request, error) {
console.log(request, error);
}
});
}
var updateDatas(data) = function(){
# replace whatever you want in the DOM with your datas
# for example:
# $('.site_title').empty();
# $('.site_title').append(data.site_title);
}