0

我有以下代码块:

(function() {
    QUnit.config.testTimeout = 10000;

    var stringformat = QUnit.stringformat;

    module('Web API GET Result has expected shape');



    asyncTest('HomeData should return an array of Sets with their info as well as cards with their info, but no sides',        
        function () {
            $.ajax({
                    url: '/sample/url',
                    dataType: 'json',
                    success: function (result) {
                        ok(
                            !!result.item, 'Got something');
                        start();
                    },
                    error: function(result) {
                        ok(false, 'Failed with: ' + result.responseText);
                        start();
                    }
                }

            );
        }
        );

    return function () { asyncTest(); };

    }

我正在尝试对具有不同结果的多个 URL 运行它,但我不知道如何使用不同的参数运行 asyncTest 两次。我尝试将函数(asyncTest 的第二个参数)分配给一个变量并将其插入 asyncTest() 但这不起作用。如何定义多个“asyncTest”并运行它们?

4

1 回答 1

0

$.deferred()、$.when() 和 $.pipe() 是你的朋友,如果你使用 jQuery [从代码中可以看出]。上面的好教程在这里这里

于 2013-03-13T18:15:36.267 回答