码迷,mamicode.com
首页 > Web开发 > 详细

mui的ajax例子1

时间:2017-07-25 10:14:46      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:link   请求   dev   pretty   script   ast   index   max   css   

mui.ajax()方法,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.ajax({
url : ‘http://m.baoxianbox.cn/index.php?m=Home&c=Index&a=ceshi‘,
type : ‘GET‘,
success : function(data){
mui.toast(data);
},
error : function(xhr,type,errorThrown){
mui.toast(type);
}
});
});
});
</script>

</html>

后端thinkphp控制器中

public function ceshi(){
if(IS_GET){
//$data=M(‘ping‘)->select();
$data=‘你好‘;
$this->ajaxReturn($data,‘json‘);
$this->display();
}
}

mui的ajax例子1

标签:link   请求   dev   pretty   script   ast   index   max   css   

原文地址:http://www.cnblogs.com/yinmeng/p/7232132.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!