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