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


    <!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>
  • 相关阅读:
    MySQL客户端执行外部sql文件命令
    Java nextInt()函数
    JSP
    托管和非托管的区别。
    FTP软件Filezilla出现“读取目录列表失败”的解决办法
    Fiddler 抓包工具总结
    wampserver:Could not execute menu item.
    重装系统怎么恢复wampserver数据
    同时安装Xcode6和Xcode7导致出现N多UUID 模拟器解决办法
    打印沙漏
  • 原文地址:https://www.cnblogs.com/zc290987034/p/8870010.html
Copyright © 2020-2023  润新知