php獲取當前頁面url AJAX如何調(diào)用PHP接口,獲取數(shù)據(jù)在前臺頁面展示?
AJAX如何調(diào)用PHP接口,獲取數(shù)據(jù)在前臺頁面展示?//js$.ajax({async: false,url:url,//后臺地址type:"GET",dataType:"json",success:
AJAX如何調(diào)用PHP接口,獲取數(shù)據(jù)在前臺頁面展示?
//js
$.ajax({
async: false,
url:url,//后臺地址
type:"GET",
dataType:"json",
success: function(data){
//data,后臺返回數(shù)據(jù)
},
error: function(){
alert("輸出錯誤")
}
})
//后臺函數(shù)
public function get_content(){
$lists = M("bbs_note")->select()//獲取數(shù)據(jù)庫數(shù)據(jù)
if(!empty($lists)){
$this->ajaxReturn($lists)//返回數(shù)據(jù)
}
}