MUI之ajax获取后台接口数据

  mui.plusReady(function() {
          getToDoNum();
 });    
  function getToDoNum(){   
      mui.ajax("接口地址", { 
          data: {
                  task_tenantId:"f0fd6e1f-cf85-11e7-98b1-fa163e00a2e7",
                  task_formKey:"pid-88fa484b-2d67-4e6e-8967-b9521cc5ef52"
              },
         dataType: 'json',
         contentType: 'application/json;charset=utf-8', //服务器返回json格式数据
         type: 'POST', //HTTP请求类型
         timeout: 10000, //超时时间设置为10秒;
         headers:{"Authorization":"Basic YWRtaW46YWRtaW4="},    //接口权限,用户名和密码    
         success: function(result,status,xhr) {
             console.log(result)
             document.getElementById("toDoNum").innerHTML=result.count; 
         },    
         error: function(xhr,status,err) {    
             mui.each(xhr,function(i){   
                 console.log(xhr[i])  
            })
             console.log(err)
             plus.nativeUI.closeWaiting();
         }
     });
 }

  

posted on 2017-11-27 11:15  木之子梦之蝶  阅读(6149)  评论(0编辑  收藏  举报

导航