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();
         }
     });
 }
相關文章
相關標籤/搜索