JavaScript传递参数方法

时间:2022-05-14 21:28:06

1、SetTimer传递参数

setTimeout(function (obj) {
    obj.myScroll = new IScroll('#wrapper', { click: true });
    obj.myScroll.on('scrollStart', function () {
        document.activeElement.blur();
    });
    obj.myScroll.on('scrollEnd', function () {

        if (obj.isMore === false) {
            obj.setScrollHeight();
            return;
        }
        if (this.y <= this.maxScrollY) {
            if (obj.isMore === false) {
                obj.setScrollHeight();
                this.refresh();
                return;
            }
            if (obj.getData !== null) {
                obj.getData();
            }
            this.refresh();
        } else {
            this.refresh();
        }
    });
}, 100,this);

2、AjaxSuccess传递参数

var obj = this;
var url = this.url;
//有分页标志才启用分页参数
if (this.isUsePage) {
    url = url + "&pageIndex=" + this.pageIndex + "&pageSize=" + this.pageSize;
}
$.ajax({
    url: url,
    type: "post",
    dataType: "json",
    data: this.datas,
    success: function (p_datas) { obj.isLoading = false;
    },

 注意红色部分