开发者

jquery ajax call does not stop repeating over and over again

Hello everyone I've never had a problem which i cant solve with google... So this is the code:

function loadData(url, type){
        loading_show();  
        var quality = getCheckedRadio();
        $.ajax
        ({
            type: "POST",
            url: "http://.../core.php",
            data: "url="+url +"&quality="+quality +"&type="+type,
            success: function (msg)
            {
                $("#url").ajaxComplete(function(event, request, settings)
                {
                    //loading_hide();
                    //$("input[type=button]").removeAttr("disabled");         
                    $("#url").html(msg);
                    window.onload=$("#url").fadeIn('slow');
                });
            }
        });
        return false;
}
function getmp3(id){
        var quality = getCheckedRadio();
        $.ajax
            ({
    开发者_JAVA技巧            type: "POST",
                url: "http://.../core.php",
                data: "id="+id +"&quality="+quality,
                success: function (msgs)
                {
                    $("#dload").ajaxComplete(function(event, request, settings)
                    {
                        loading_hide();
                        $("input[type=button]").removeAttr("disabled");         
                        $("#dload").html(msgs);
                        window.onload=$("#dload").fadeIn('slow');
                    });
                }
            });
}

So, the first function works just fine, the core.php returns some html data and a javascript: " getmp3('bla'); " so it fires the second function. The problem is that the $.ajax in the 'getmp3' function repeats over and over again and it floods the browser. It does what it has to but it just doesnt stop calling over and over.


You don't need the ajaxComplete functions, you can put the code directly in the success function.

function loadData(url, type){
        loading_show();  
        var quality = getCheckedRadio();
        $.ajax
        ({
            type: "POST",
            url: "http://.../core.php",
            data: "url="+url +"&quality="+quality +"&type="+type,
            success: function (msg)
            {
                    //loading_hide();
                    //$("input[type=button]").removeAttr("disabled");         
                    $("#url").html(msg).fadeIn('slow');
            }
        });
        return false;
}
function getmp3(id){
        var quality = getCheckedRadio();
        $.ajax
            ({
                type: "POST",
                url: "http://.../core.php",
                data: "id="+id +"&quality="+quality,
                success: function (msgs)
                {
                        loading_hide();
                        $("input[type=button]").removeAttr("disabled");         
                        $("#dload").html(msgs).fadeIn('slow');
                }
            });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜