Jump to content

Undefined Error


Mekaboo
 Share

Recommended Posts

Hey all!!

Uncaught ReferenceError: jQuery is not defined
    jQuery 2

I added the most recent JQuery(standalone and CDN) and still getting this error. How do I get rid of this please?

Thank ya☺️

Link to comment
Share on other sites

Without seeing any of your code it is hard to know what is causing the problem. This could happen if your <script> tag occurs before the <script> tag which loads the jQuery library.

  • Like 1
Link to comment
Share on other sites

Sorry about that @Ingolme

[code]

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
 
     <script type="text/javascript">
$(document).ready(function(){
        windowOnScroll();
});
function windowOnScroll() {
       $(window).on("scroll", function(e){
        if ($(window).scrollTop() == $(document).height() - $(window).height()){
            if($(".post-item").length < $("#total_count").val()) {
                var lastId = $(".post-item:last").attr("id");
                //getMoreData(lastId);
            }
        }
    });
}

function getMoreData(lastId) {
       $(window).off("scroll");
    $.ajax({
        url: 'getMoreData.php?lastId=' + lastId,
        type: "get",
        beforeSend: function ()
        {
            $('.ajax-loader').show();
        },
        success: function (data) {
               setTimeout(function() {
                $('.ajax-loader').hide();
            $("#post-list").append(data);
            windowOnScroll();
               }, 1000);
        }
   });
}
</script>

[/code]

Edited by Mekaboo
Link to comment
Share on other sites

Just running that code in my own HTML document does not result in any errors.

You shouldn't include the jQuery library twice. Either load it from the CDN or from your own server, but not both places. I would recommend loading it from the CDN for now to avoid errors with file paths.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...