mercredi 1 juillet 2015

Jquery Sometime Working fine and sometime giving "Uncaught TypeError: undefined is not a function"

Here is my script tag

Sometime It loaded all the pages, sometime few and giving the following error: Uncaught TypeError: undefined is not a function

Earlier I searched on the web about the same error, someone suggested to use jQuery.noConflict(),jQuery.noConflict(true)

I stored the value of jquery no conflict int a variable named j and replaced the jquery sign($) with j, but it didn't work. Also tried with passing a true value to no conflict as suggested by someone else on the forums, but no solution the problem.

Any help appreciated!

<script>
    //var j = jQuery.noConflict(true);
    $(document).ready(function () {
        $('#loading_status').hide();
        var total_row =946;
        var per_page = 15;
        var total_page = parseInt(total_row / per_page);

        var current_page = 0;
        var loadable = true;

        var loadNextPage = function (start, rows) {
            $('#loading_status').show();
            $.ajax({
                url: 'http://ift.tt/1dz7kgE',
                type: 'post',
                data: {
                    page: 0,
                    start: start,
                    records: rows
                },
                success: function (result) {
                    $("#flushed").append(result);
                    loadable = true;
                    $('#loading_status').hide();
                },
                error: function (xhr, status, error) {
                    alert("Error code: " + xhr.status + "\n\n\nError message: " + xhr.responseText);
                }
            });
        };

        loadNextPage(current_page, per_page);

        $(window).scroll(function () {
            if (($(window).scrollTop() + $(window).height()) >= ($(document).height() - 1000) && current_page < total_page && loadable == true) {
                loadable = false;
                current_page++;
                var start = (current_page * per_page) + 1;
                loadNextPage(start, per_page);
            }
        });

    });
</script>

Aucun commentaire:

Enregistrer un commentaire