📜  如何在 jquery 中添加 ajax 加载图标 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:16.243000             🧑  作者: Mango

代码示例1
jQuery.fn.ajax = function(options)
{
    var $this = $(this);
    debugger;
    function invokeFunc(func, arguments)
    {
        if ( typeof(func) == "function")
        {
            func( arguments ) ;
        }
    }

    function _think( obj, think )
    {
        if ( think )
        {
            obj.html('
Loading ...
'); } else { obj.find(".loading").hide(); } } function makeMeThink( think ) { if ( $this.is(".ajax-loading") ) { _think($this,think); } else { _think($this, think); } } options = $.extend({}, options); // make options not null - ridiculous, but still. // read more about ajax events var newoptions = $.extend({ beforeSend: function() { invokeFunc(options.beforeSend, null); makeMeThink(true); }, complete: function() { invokeFunc(options.complete); makeMeThink(false); }, success:function(result) { invokeFunc(options.success); if ( options.load ) { $this.html(result); } } }, options); $.ajax(newoptions); };