npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

jquery.ajaxs

v1.2.0

Published

Send jQuery ajax requests one by one or pararell

Downloads

9

Readme

jQuery Ajaxs Plugin

Send jQuery ajax requests one by one or pararell

//two ajaxs requests one by one
$.ajaxs([{
		url: '/task/1',
		data: 'myparam=testing',
		method: 'post'
	},{
		url: '/task/2',
		method: 'post'
	}], {
		maxParallel: 1
	})
	.done(function() {
		console.log('Both task done one by one!');
	})
	.fail(function(jqXHR, textStatus, errorThrown) {
		console.log('Something was wrong :( ', errorThrown);
	});

Methods

Methods library


$.ajaxs(ajaxs [, settings]): AjaxsPromise

Call jQuery ajaxs requests one by one or parallel

Arguments

  1. ajaxs (Object[]) An array of jQuery ajax request settings
  2. settings (Object: optional) jQuery Ajaxs Settings

Returns

AjaxsPromise: The jQuery promise object extended


$.ajaxsManager(): AjaxsManager

Like a builder object to call $.ajaxs easily

Returns

AjaxsManager

Settings

Ajaxs Settings


maxParallel

type: int
default: 1
How many requests can be processed simultaneously. Set 0 for no limit

AjaxsManager Methods


setMaxParallel(maxParallel): AjaxsManager

Set maxParallel setting

Arguments

  1. maxParallel (Int)

Returns

AjaxsManager


add(settings): AjaxsManager

Add one more request to call

Arguments

  1. settings (Object) jQuery ajax request settings

Returns

AjaxsManager


abort(): AjaxsManager

Aborts the ajaxs

Returns

AjaxsManager


run(): AjaxsManager

Run all the ajax requests added

Returns

AjaxsPromise: The jQuery promise object extended

AjaxsPromise Methods


A jQuery Promise object with done, fail, always, pipe... functions.

The deferred is resolved with the last resolve's ajax
The deferred is rejected with the first reject's ajax


abort(): AjaxsPromise

Aborts the ajaxs

Returns

AjaxsPromise

Examples

test.php

<?php
if (isset($_GET['pos'])) {
    usleep(rand(300, 1000)*1000);
    echo "pos: ".$_GET['pos'];
    exit;
}

jQuery Ajax requests

var total = 4;
var ajaxs = [];
for (var i=0; i<total; i++) {
    ajaxs.push({
        url: 'test.php',
        data: {
            pos: i
        },
        success: function(data) {
            console.log('Done! '+data);
        }
    });
}

One by one

$.ajaxs(ajaxs, {
		maxParallel: 1
	})
    .done(function() {
        console.log('Finished OK');
    })
    .fail(function(jqXHR, textStatus, errorThrown) {
        console.error('Finished ERROR ', textStatus, errorThrown);
    });
Ouput:
Done! pos: 0  
Done! pos: 1  
Done! pos: 2  
Done! pos: 3  
Finished OK

Parallel

$.ajaxs(ajaxs,
	{
		maxParallel: 3
	})
    .done(function() {
        console.log('Finished OK');
    })
    .fail(function(jqXHR, textStatus, errorThrown) {
        console.error('Finished ERROR ', textStatus, errorThrown);
    });
Ouput:
Done! pos: 2  
Done! pos: 1  
Done! pos: 0  
Done! pos: 3  
Finished OK

Manager

$.ajaxsManager()
	.setMaxParallel(0)
	.add({
		url: 'test.php',
		data: {
			pos: 1
		}
	})
	.add({
		url: 'test.php',
		data: {
			pos: 2
		}
	})
	.run()
	.done(function() {
		console.log('Finish OK!');
	})
	.fail(function() {
		console.log('Finish Error ', arguments);
	});