AjaxQ

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-11 20:14:45

软件介绍

AjaxQ is a jQuery plugin that implements AJAX request queueing mechanism.

Why?

There are several reasons why you may need to queue AJAX requests and run them in a sequential manner:

  • Browsers impose a limit on the number of open connections to the server. All requests that do not fit in the limit are going to wait for being run anyway. Internet Explorer does not open more than 2 connections per server at a time by default. Mozilla Firefox, Opera and Safari have a limit of 8 connections per server.
  • Sometimes it is essential to avoid flooding the server with plenty of simultaneous AJAX requests.
  • Web application needs AJAX requests to run one by one by design, the order is important.

How?

Assume that the web application has to make two AJAX requests. Here's the usual and the simplest way of doing it:

$.ajax ({
    url: "test_1.html",
    cache: false,
    success: function(html)
    {
        $("#results").append(html);
    }
});

$.ajax ({
    url: "test_2.html",
    cache: false,
    success: function(html)
    {
        $("#results").append(html);
    }
});

The requests will run almost simultaneously. Moreover, the response to the second request may come first.

Let's look at how to use AjaxQ plugin, and make the requests run in a sequential manner:

$.ajaxq ("testqueue", {
    url: "test_1.html",
    cache: false,
    success: function(html)
    {
        $("#results").append(html);
    }
});

$.ajaxq ("testqueue", {
    url: "test_2.html",
    cache: false,
    success: function(html)
    {
        $("#results").append(html);
    }
});

Now the first requests runs first, and the second request runs only when the first one finishes.

There are only two essential differences between these two code blocks:

  • The method name changes from $.ajax() to $.ajaxq().
  • $.ajaxq() gets one more parameter, the name of the queue. Queue name comes first, and request options come second.

Notes

The number of AJAX queues is not limited. Web application may have as much AJAX queues as it requires. However, consider the limit of browser connections in case you have two or more queues running at the same time.

API

$.ajaxq (queue, options)
Enqueues a new AJAX request. The first parameter is a string denoting the name of the queue. The second parameter is a collection of request settings (see jQuery documentation for details).

$.ajaxq (queue)
Stops the current AJAX request and clears the queue. The function parameter is a string denoting the name of the queue.

本文地址:https://codercto.com/soft/d/23173.html

乔纳森传

乔纳森传

利恩德·卡尼 / 汪琪 岳卉 王文雅 / 中信出版社 / 2014-1-1 / 49

抛开苹果公司,单就设计行业来讲,乔纳森也是一个特殊的人物。他推动了设计行业的大变革:不再为产品增加看起来炫得多的配件,而是要去掉多余的东西。 ——陈向东 终于有一本书能够如此地接地气:它不再关注那位神一样的乔布斯,而是关注那位站在神的背后,同样具有神一样光环的乔纳森。 ——孙陶然 乔纳森•艾夫把他自己对科学、人文、艺术,乃至整个世界的感知尽数渗透进苹果的设计和审美之中,他是......一起来看看 《乔纳森传》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具