Blogger Information
Blog 175
fans 1
comment 0
visits 384411
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
api.ajax封装带回调方法
dxp2tq的博客
Original
2087 people have browsed it

**********************common.js**********************************

//封装方法ajax

var config_method = {

  'config_ajax':function(){},

}


config_method.config_ajax = function(param) {

    console.log(JSON.stringify(param));

    console.log("ajax请求");

    api.ajax({

        url: param.pathName,

        method: 'post',

        data: {

            values: param.ajaxData

        }

    }, function(ret, err) {

        console.log("进入ajax");

        if (ret) {

            console.log('成功:' + JSON.stringify(ret));

            if (param.method) {

                console.log("有回调方法");

                param.method(ret); //调用方法

                return;

            }

            console.log("无回调方法");

        } else {

            console.log('失败' + JSON.stringify(err));

            api.toast({ //错误提示信息

                msg: err.msg, //错误信息

                duration: 2000, //显示时间长度

                location: 'bottom' //显示位置

            });

            return;

        }

    });

}

**********************************调用*******************************************

config_method.config_ajax({

            'pathName': 'url地址'

            'ajaxData': {

                userId: userInfo.uid,

            },

            'method': callbackfnOperatePhone

        });


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post