Incessant spinning circle animation in Javascript persists without pause during page loading

After spending several hours on it, I'm still struggling to understand why my code isn't working.

The goal is to create an animation of a spinning circle during the page load. The code I have so far accomplishes this, but the issue is that it never stops, preventing the rest of the page from loading.

Javascript:

// Waiting for window load
$(window).load(function() {
    // Fading out the loader animation
    $(".se-pre-con").fadeOut("slow");;
});

HTML: Just a simple div with a specific class

<div class="se-pre-con"></div>

CSS

.no-js #loader {
    display: none;
}

.js #loader {
    display: block;
    position: absolute;
    left: 100px;
    top: 0;
}

.se-pre-con {
    position: fixed;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: url(images/loader-64x/Preloader_2.gif) center no-repeat #fff;
}

NOTE: I followed this tutorial:

OTHER NOTE: This is specifically for an ASP.NET MVC application

Answer №1

It turns out that the solution to my issue was quite straightforward. I just needed to ensure that I called my script after rendering jQuery. Initially, my header code looked like this:

<head>
    <script type="text/javascript" src="~/Scripts/LoadSpinner.js">
</script>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <title>@ViewBag.Title - DeviceManagment</title>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
</script>
</head>

The simple fix involved rearranging the order in which I included my JavaScript files.

While it may seem like a small adjustment, I hope that sharing this solution might assist others facing similar challenges.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using "overflow-x: hidden" is ineffective on mobile devices

I'm facing an issue where the CSS property overflow-x: hidden is not working on mobile devices. Here is a snippet of my HTML code: <div class="topbar"> <div class="navbar-brand float-left"> <a href="#"><img src="asset ...

Do styles operate differently depending on whether they are within the HTML head tags or not?

I am currently working on a project to create a simple website where a div containing text is centered both horizontally and vertically on the page. Despite thinking this would be a straightforward task, I encountered some strange issues. Let's refer ...

The issue with Selenium chromedriver is that it is failing to execute the JavaScript scripts

Normally, the page loads like this: https://i.sstatic.net/GHSb4.png However, when opened with Chrome driver via Selenium in Python, it loads like this: https://i.sstatic.net/dO3Q2.png I have been trying to figure out how to execute JavaScript scripts on ...

preventing the dropdown navigation bar from causing elements to shift to the side

I am facing an issue with my dropdown navigation bar where elements such as buttons or images get pushed to the right side when the drop-down options appear. How can I prevent this from happening? Navbar: <nav id="nav1"> ... CSS: nav#nav1 li a { ...

Control color changes through animation with Three.js

I'm having difficulty adjusting the tint color for this animation in Three.js. No matter what color I apply, such as #008080 for green, the actual color appears as blue or something else. It seems like there is a calculation affecting the highlight co ...

Crack open a JSON object

I am struggling to parse a JSON object. It seems like the code is not working, can you help me? var mock_data = { "available": [{ "UserID": 7, "UserName": "Manoj", "Language": "Java", "Score": 9, "TimeLimit": 4.0 }, { "UserID ...

Submission of the form was cancelled, causing a loop to occur

I'm encountering an issue with submitting a file through a standard HTML form. After uploading the file, the process seems to get trapped in a continuous loop where the file keeps uploading repeatedly. The submission of the form is done using jQuery, ...

Angular-UI/Bootstrap: Experimenting with a controller incorporating a dialog box

Hello there, I have a controller that utilizes a Dialog from the angular-ui/bootstrap framework: function ClientFeatureController($dialog, $scope, ClientFeature, Country, FeatureService) { //Get list of client features for selected client (tha ...

Transitioning from clip to clip-path in order to utilize percentage values

My current approach involves using a scss-based animation to create border animations with movement. The animation's core functionality relies on the use of clip. $box-width: 80px; $box-height: 50px; @keyframes clipMe { 0%, 100% { ...

Transforming Form Input Fields into a Nested JSON Format with the Power of JQuery

I'm facing a challenge in converting the input fields below into a nested JSON file structure in my HTML page. Despite trying various methods, I haven't been successful yet. These inputs are retrieved through AngularJS ng-repeat. Any assistance o ...

Default cursor for Internet Explorer: automatic

I have a container div that holds all of my website's content. I want this container to change the cursor to a pointer when clicked on, but I don't want the elements inside the container to inherit this cursor style: https://i.sstatic.net/8joJo. ...

What is the best way to determine the width of a scroll bar?

Are you familiar with any techniques that work across multiple browsers? ...

Filtering an array of objects by multiple arrays of keys

My data set consists of an array of objects const Data = [ {first_name: 'Ammy', city_name: 'LA', age: 22, designation: 'officer'}, {first_name: 'Dave', city_name: 'Paris', age: 23, designation: 'en ...

Dragging and dropping an HTML canvas element causes its width and height to be reset to zero

I am currently developing a customizable dashboard that allows users to rearrange dashboard tiles (represented by div elements) and position them anywhere within the dashboard. HTML Structure The HTML structure is outlined in the snippet below: <div cl ...

Determining the specific image button clicked in a datalist

When I click an image button in a datalist, I want to change the imageUrl. Therefore, I need to retrieve a specific property of the imagebutton in the datalist. Here is my code: <asp:DataList ID="datalistcevaplar" runat="server" Width="740px ...

Choose an option and use JQuery to show relevant content

After going through countless threads, I am still unable to find the right solution to my problem for my first question. My Goal: I want to create a select box with multiple options. Each option should be linked to a JQuery script that will display a re ...

Tips for safeguarding user input data in the event of a Jeditable ajax post failure

Seeking a solution with Jeditable for retaining textarea data and keeping the form visible in case of failed ajax post due to issues like network problem or server error. Is there a way to achieve this with Jeditable? Thanks! ...

Creating interactive forms (the optimal method)

My project involves creating an Android Tablet application that will connect to a web service to retrieve dynamic forms which can be filled offline and then submitted when online. These forms are not predefined, and may contain attached images. However, I ...

Mastering the settimeout function for rotating a cube in three.js: Best practices and tips

I am currently developing a program that will rotate a cube based on quaternion data inputted by the user via a CSV file in an HTML format. The JavaScript code cycles through each quaternion in the dataset, applying them to the cube at regular intervals to ...

Issue with Django not executing Bootstrap Mobile Toggle properly

In my Django project, I have successfully loaded Bootstrap4 with min.css/js files in my stylesheet references. However, the mobile toggle menu is not working when clicked. There are no errors in the browser source, so it seems like there might be a missi ...