mui ajax

作者: bianruifeng | 来源:发表于2019-06-30 09:47 被阅读0次

拼接、组装、格式化数据,常用工具Jason在线校验编辑

function getdata() {
        var params = {
            page: count, //当前页
            rows: 5, //一页的条数
        }
        var data = app.createPostData(params);//组装
        mui.ajax(apiUrl , {
            data: data,
            dataType: 'json', //服务器返回json格式数据
            type: 'post', //HTTP请求类型
            timeout: 10000, //超时时间设置为10秒;
            beforeSend: function(e) {
                plus.nativeUI.showWaiting('...');
                
            },
            complete: function(e) {
                console.log(JSON.stringify(e));
            },
            success: function(rsp) {
                plus.nativeUI.toast('成功');
                console.log("rsp: " + JSON.stringify(rsp));

                var items= rsp.items;
                mui.each(items,function(index,item){
                    var id = item.id,
                    name = item.album.name,
                    author = item.artists[0].name,
                    picUrl = item.album.picUrl,
                    audio = item.audio;           
                })
            },
            error: function(xhr, type, errorThrown) {
                plus.nativeUI.toast(xhr.status + '请求失败,请稍后再试');
                console.log(xhr.status);
                console.log(errorThrown);
            }
        });
    }

相关文章

网友评论

    本文标题:mui ajax

    本文链接:https://www.haomeiwen.com/subject/qumvcctx.html