mui ajax php实例,mui的ajax例子3

  • Post author:
  • Post category:php


mui.get()

前端頁面:


測試

點擊測試

mui.init();

mui.plusReady(function(){

document.getElementById(‘btn1’).addEventListener(‘tap’,function(){

mui.get(‘http://m.baoxianbox.cn/index.php?m=Home&c=Index&a=ceshi’,{category:’news’},function(data){

//獲得服務器響應

if(data.code==0){

mui.toast(data.msg);

}else{

mui.toast(data.msg);

}

},’json’

);

});

});

后端thinkphp控制器內:

public function ceshi(){

if(IS_GET){

if($_GET[‘category’]==’news’){

$returnData=array(‘code’=>0,’msg’=>’已查到’);

}else{

$returnData=array(‘code’=>1,’msg’=>’未查到’);

}

$this->ajaxReturn($returnData,’json’);

$this->display();

}

}