zoukankan      html  css  js  c++  java
  • 当连续进行多个请求,并且请求的url地址相同时。放弃前面的所有请求,只执行最后一次请求。

    // 当连续进行多个请求,并且请求的url地址相同时。放弃前面的所有请求,只执行最后一次请求。
    function ajaxFilter(){
    var pendingRequests = {};
    jQuery.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
    var key = options.url;
    console.log(key);
    if (!pendingRequests[key]) {
    pendingRequests[key] = jqXHR;
    }else{
    //jqXHR.abort(); //放弃后触发的提交
    pendingRequests[key].abort(); // 放弃先触发的提交
    }
     
    var complete = options.complete;
    options.complete = function(jqXHR, textStatus) {
    pendingRequests[key] = null;
    if (jQuery.isFunction(complete)) {
    complete.apply(this, arguments);
    }
    };
    });
    }
  • 相关阅读:
    程序员学习提高必看的一篇文章
    SpringAOP拦截器的代理机制
    springboot03_RabbitMQ
    Docker_02
    Docker_01
    Redis_02
    Redis_01
    关于Linux下内存和Swap
    密码学DAY2
    密码学DAY1_02
  • 原文地址:https://www.cnblogs.com/amaoegg/p/10675383.html
Copyright © 2011-2022 走看看