jquery版本更新后jquery函数无法正常工作

时间:2014-03-25 14:23:29

标签: javascript jquery ajax

好的,所以我使用jquery 1.8.3这个功能运行良好,但是当我使用jquery 1.10.x或更高版本时它不再有效。

<script type="text/javascript">
    $.ajaxSetup({cache: false});
    $(document).ready(function() {
        // set up the click event
        $('a.groups_loader').on('click', function() {
            var toLoad = '<? echo base_url(); ?>user/account_groups/';
            $('.groupsajax').fadeOut(100, loadContent);
            $('#load').remove();
            $('#groupswaiting').append('<div id="load" style="height: 400px;"><div id="loader-arm"><div id="loader-lp"><div id="loader-baLabel"></div></div><div id="loader-reflect"></div></div></div>');
            $('#load').fadeOut(1000);
            function loadContent() {
                $('.groupsajax').load(toLoad, '', function(response, status, xhr) {
                    if (status == 'error') {
                        var msg = "Sorry but there was an error: ";
                        $(".groupsajax").html(msg + xhr.status + " " + xhr.statusText);
                    }
                }).fadeIn(4000, hideLoader());
            }
            function hideLoader() {
                $('#load').fadeOut(2000);
            }
            return false;
        });
    });
</script>

我想知道改变了什么以及如何解决这个问题。感谢

1 个答案:

答案 0 :(得分:0)

如果它帮助其他人......问题不在上面的脚本中,而是在页面上的另一个类似的(ajax)脚本中。在上面的脚本中,我已将.live('click', function()更新为.on('click', function(),因为.live已在JQ的更高版本中弃用。但是,页面上的另一个脚本尚未更新,仍然使用.live,这阻止了上述脚本的工作。因此,不要一次尝试解决一个脚本问题,请确保先将它们全部更新!

相关问题