1

jquery-mockjax ライブラリを使用して ajax をモックしようとしていますが、応答がありません。私のコードは次のとおりです。

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="components/jquery/jquery.js"></script>
    <script src="components/jquery-mockjax/jquery.mockjax.js"></script>
    <script>
        $(function(){
            $.mockjax({
                url: '/test/inline',
                contentType: "text/json",
                responseTime: 0,
                responseText: {
                    say: 'Hello world!'
                }
            });

            $('#btn').click(function(){
                $.ajax({
                    url: '/test/inline',
                    type: "GET",
                    dataType: 'json',
                    success: function(json) {
                        alert('You said: ' + json.say);
                    },
                    complete: function() { 
                        $.mockjaxClear(); 
                        alert('completed');
                    }
                });
            }
            );
        });
    </script>
</head>
<body>
    <button id="btn">Get</button>
</body>
</html>

不足しているものはありますか?

4

2 に答える 2

2

私はこれと同じ問題を抱えていて、30分間頭を叩いて、「なぜ?」と叫んでいました。

jQuery を 1.* にダウングレードしてみてください。

于 2013-05-31T06:18:27.833 に答える
0

応答時間の増加。

responseTime: 10,
于 2013-05-07T06:15:06.347 に答える