mui.get()
前端页面:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="css/mui.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="css/iconfont.css"/>
<script src="js/mui.min.js"></script>
<script type="text/javascript" charset="utf-8">
</script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">测试</h1>
</header>
<div class="mui-content">
<button type="button" id="btn1">点击测试</button>
</div>
<script type="text/javascript">
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'
);
});
});
</script>
</html>
后端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();
}
}