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

mui APP与服务器之间的交互原理

时间:2018-04-17 21:21:15      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:imu   服务   css   mui   link   utf-8   char   提前   har   

 

 

<!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>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <script type="text/javascript" charset="utf-8">
    /*提前预加载其他页面,这样再打开已加载好的页面就会有很好的效果了*/
          mui.init();
    </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">hello</h1>
</header>

<div class="mui-content">
    <button type="button" id="btn1"> 获取服务器端数据</button>
</div>
    
</body>
<script type="text/javascript">
mui.init();
mui.plusReady(function(){
    document.getElementById(btn1).addEventListener(tap,function(){
        mui.ajax({
            url      : http://demo.hcoder.net/index.php,
            type     : GET,
            success  : function(data){
                mui.toast(data);
            },
            error    : function(xhr,type,errorThrown){
                mui.toast(type);
            }
        });
    });
});
    
    
    mui.post(http://server-name/login.php,{
        username:username,
        password:password
    },function(data){
        //服务器返回响应,根据响应结果,分析是否登录成功;
            ...
        },json
    );
        
    mui.get(http://server-name/list.php,{category:news},function(data){
        //获得服务器响应
        ...
        },json
    );
    mui.getJSON(http://server-name/list.php,{category:news},function(data){
        //获得服务器响应
        ...
        }
    );
</script>
</html>

 

mui APP与服务器之间的交互原理

标签:imu   服务   css   mui   link   utf-8   char   提前   har   

原文地址:https://www.cnblogs.com/zc290987034/p/8870010.html

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