mui APP與服務器之間的交互原理
阿新 • • 發佈:2018-04-17
加載 news ces content row title success html plus
<!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與服務器之間的交互原理