zoukankan      html  css  js  c++  java
  • 将数据加载时显示的图片和文字提成公共的--实现方法

    1. 页面引入loading.js。且在页面上添加<div id="loading"></div>
    2. 加载数据之前进行调用。调用方法如下:
    loading = new loadingObj($("#loading"), buildURI("images/"));
    loading.init();
    loading.show();
    $("#service_slist").hide();
    $("#listArea").empty();
    $("#pageArea").empty();
    $("#fw_empty").hide();
    if(typeof window.xhrCache != 'undefined') {
        typeof window.xhrCache.abort == 'function' && window.xhrCache.abort();
    }
    window.xhrCache = $.ajax( {
        type : "post",
        dataType : "text",
        url: url,
        data: data,
        success :     function(res){    
            loading.hide();
            ………………………………
            }
        });

    loading.js

    var loadingObj = function(viewObj, imgPathPrefix){
        var imgName = "loading_pa.gif";
        this.css = ".loading_box{background:url("+ imgPathPrefix + imgName +") center top no-repeat; padding-top:30px; 100%; font-size:12px; text-align:center; color:#cccccc;}";
        this.html = "<div class='loading_box'>正在加载中,请稍后...</div>";
        this.viewObj = viewObj;
    }
    
    loadingObj.prototype = {
        init: function(){
            var style = $("<style>"+ this.css +"</style>");
            var head = $("head").length > 0 ? $("head").eq(0) : $("head");
            style.appendTo(head);
            this.viewObj.html(this.html);
        },
        show: function(){
            this.viewObj.show();
        },
        hide: function(){
            this.viewObj.hide();
        }
    };
  • 相关阅读:
    CF140CNew Year Snowmen
    ZR10.1青岛集训三地联考
    CF1228——记一次和紫名失之交臂的CF
    CF1220
    codeforce 382 div2 E —— 树状dp
    codeforce 381 div2
    codeforce 380(div.2)
    Bishops Alliance—— 最大上升子序列
    codeforce 379(div.2)
    模板——BigInteger
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/3547751.html
Copyright © 2011-2022 走看看