jquery 封装的ajax调用

(function(){
    var Ploy = {
        Config: {
            ajaxUrl: "/ajax/ploy.ashx"
        },
        ajax: function(params, callback) {
            var that = this;
            $.ajax({
                type: "get",
                cache: false,
                dataType: "json",
                url: that.Config.ajaxUrl,
                data: params,
                success: arguments[1] || function(){},
                error: arguments[2] || function(){
                    if (window.console) {
                        console.log("error log: " + data.responseText);
                    }
                }           
            });
        },
        GetBag: function(){
            var that = this;
            var params = {
                ajaxMethod: "getbookbag",
                random: Math.random()
            };
            var suc = function(data){                
                if(data.isSuccess === 1){
                    Common.ShowMessageGo(data.msg, location.href);
                } else if(data.isSuccess === -1){
                    Common.login();
                } else {
                    tar.disabled = false;
                    Common.ShowMessage(data.msg);
                }
            };
            var err = function(){
            };
            that.ajax(params, suc, err);
        }
    };
    window.Ploy = Ploy;
})();

posted @ 2013-12-02 18:00  (二少)在南极  阅读(479)  评论(0编辑  收藏  举报