jQuery Deferred

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-08 10:43:07

软件介绍

Simple and clean asynchronous/nonblocking processing system JSDeferred (is like MochiKit and with some extension) with jQuery supports.

jQuery supports: overwrite ajax functions get, post and getJSON to return Deferred object (no arguments change).

Collect some asynchronous resources by ajax.

 

parallel([
    $.get("a.html").next(function (data) {
        return data.match(/([^<]+)<\/title>/);
    }),
    $.get("b.txt" ).next(function (data) {
        return data.match(/##\s*([^<]+)\s*##/);
    }),
    $.getJSON("c.json").next(function (data) {
        return data.title;
    })
]).next(function (values) {
    print("Titles "+values.join(", "));
});

 

Divided loop for non stress browsing. When long time processing is required, it is bad that simply using only for loop because it stops browser appearance. Deferred resolves it with bare minimum of effort.

 

loop({begin: 1, end:100, step:10}, function (n, o) {
    print(["Processing divided loop:n=", n].join(""));
    for (var i = 0; i < o.step; i++) {
        var j = n + i;
        print(j);
    }
});

 

Like tail call code. If you are habituated to functional programming, this syntax may be familiar to you.

 

next(function () {
    function pow (x, n) {
        function _pow (n, r) {
            if (n == 0) return r;
            return call(_pow, n - 1, x * r);
        }
        return call(_pow, n, 1);
    }
    return call(pow, 2, 10);
}).
next(function (r) {
    log([r, "end"]);
});

 

See more samples!

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

应用Rails进行敏捷Web开发

应用Rails进行敏捷Web开发

Dave Thomas, David Hansson等 / 林芷薰 / 电子工业出版社 / 2006-7 / 65.00元

这是第一本关于Ruby on Rails的著作。 全书主要内容分为两大部分。在“构建应用程序”部分中,读者将看到一个完整的“在线购书网站” 示例。在演示的过程中,作者真实地再现了一个完整的迭代式开发过程,让读者亲身体验实际应用开发中遇到的各种问题、以及Rails如何有效解决这些问题。在随后的“Rails框架”部分中,作者深入介绍了Rails框架的各个组成部分。尤为值得一提的是本部分的后几章......一起来看看 《应用Rails进行敏捷Web开发》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

SHA 加密
SHA 加密

SHA 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试