Issues with loading CSS and JavaScript in HTML files are common

When attempting to integrate a slider into an HTML page within my Django project, I am encountering issues with the CSS and JavaScript not loading properly. As a result, instead of having a functional slider where images slide across the screen, I am seeing only a vertical line of pictures. The browser console is showing the following errors:

Failed to load resource: the server responded with a status of 404 (Not Found)
slider.js:1 Uncaught ReferenceError: $ is not defined
    at slider.js:1
main.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
countdown.js:26 Uncaught TypeError: Cannot set property 'innerHTML' of null
    at updateClock (countdown.js:26)
    at initializeClock (countdown.js:36)
    at countdown.js:41
main.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
slider.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)

Below is the structure of my static folder:

static
-->second
---->css
       >app
         slider.css
---->js
       >app
         slider.css

Here is the code snippet from my HTML file:

{% load static %}
<link rel="stylesheet" href="{% static 'second/css/app/slider.css' %}">
<script src="https://code.jquery.com/jquery-3.5.0.min.js" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>
<script src="{% static 'second/js/app/slider.js' %}"></script>
    <div class="container">
        <h3>Our Partners</h3>
        <section class="customer-logos slider">
      [Images go here]
   </section>
</div>

This is a snippet from my JavaScript file (slider.js):

$(document).ready(function(){
    $('.customer-logos').slick({
        [Slider settings go here]
    });
});

And here is the CSS stylesheet (slider.css) for the slider:

[CSS styles go here]

If you would like to see a working example of this slider, please visit this CodePen link.

Answer №1

It appears that you may have overlooked inserting the jQuery CDN link.

<script src="https://code.jquery.com/jquery-3.5.0.min.js" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>

Please make sure to include this snippet in your HTML code.

Answer №2

Within the script tag, make sure to include the attribute type = "text/javascript"

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

Managing the backspace function when using libphonenumber's AsYouTypeFormatter

I've been attempting to integrate the google-libphonenumber's AsYouTypeFormatter into a basic input field on a web form. For each key pressed by the user, I feed it into the inputDigit method. However, I've encountered an issue where when th ...

HTML's JavaScript is loaded prior to the completion of ng-include

I am facing an issue where my HTML file loads the .js and .css before the ng-include has finished. As a result, these libraries cannot find the elements that are loaded in the include. For example: <html> <head> <link href="as ...

Guide to removing an element without a specific parent reference

I need to remove list items that do not have a parent of ul This is the HTML snippet provided: <div class="yamm-content"> <div class="row"> <li> <a href="#">Should be deleted</a> </li> < ...

Updating HTML using Angular JS with a nested dictionary is a breeze

As a newcomer to AngularJS, I am facing an issue with my code. I have created a dictionary in the controller scope and populated it after an HTTP request (key, value pair). The dictionary is being created successfully and there are no errors, but the HTML ...

Custom Wikipedia HTML template for a unique and immersive user experience

I am looking to develop a wiki website similar to Wikipedia using .Net, but I am having difficulty finding an HTML template that resembles it. Can anyone provide information on the template or framework used by Wikipedia and where I can get it? ...

Exploiting the :target selector to customize numerous elements

My objectives: Create a single HTML document that consolidates all my content for easier copying. Incorporate multiple "pages" within the document to highlight different data sections. Ensure seamless functionality of the browser's back button and s ...

Mastering the incorporation of Context in React with Typescript

I am currently in the process of setting up a context provider for my Next.js application using TypeScript. Although I have previously set up a context provider in React using plain JavaScript, this time I am delving into learning TypeScript. In the code ...

Enhance Your Wordpress Site with jQuery TimeEntry Plugin

I am currently working on integrating a Time range field into my Wordpress page. Can someone please guide me on where to insert the code and how to display the range text box on my page? $('.timeRange').timeEntry({beforeShow: customRange}); f ...

How can I convert JSON data from an array to an array of objects using JavaScript?

My goal is to load data into an ag-grid. I have obtained the json data in the following format: {"my_data":{"labels":[1,2,3,...], "idx":["idx1", "idx2", ...]}} In order to pass it to the grid, I need to transform it to this format: {"my_data":[{"labels" ...

The most recent axios request yielded a null response

I needed to retrieve the current weather conditions of a specific location, so I decided to utilize two different APIs. The first one being Mapbox, which helped me convert the place name to geo-coordinates. The second API I used was Accuweather. Additional ...

Steps for building a Bootstrap grid of thumbnails

I need to display an unknown number of thumbs. Below is a sample of the HTML rendered: <div class="row-fluid"> <ul class="thumbnails"> <li class="span3"> <a href="#" class="thumbnail"> &l ...

Adjusting the timing of a scheduled meeting

Is there a way for me to update the time of a Subject within my service? I'm considering abstracting this function into a service: date: Date; setTime(hours: number, mins: number, secs: number): void { this.date.setHours(hours); this.date.s ...

Adding input fields that change dynamically along with their corresponding radio buttons using AngularJS

Hello, I am struggling with implementing a feature in my HTML and AngularJS files (using Bootstrap ui). I want to create a new input field (td) along with three corresponding radio buttons when the user clicks on an add button. I have attempted to modify t ...

Utilize express compression in Node.js to compress JSON data from the REST API endpoint

I recently developed a small RESTful application using Node.js. I attempted to compress the JSON data returned by an API request using Express and compression, but unfortunately it did not work as expected. var express = require('express'); var ...

Error: content within v-html directive not displaying as expected

The v-html content is not rendering correctly for me. Interestingly, when I remove the v-html in the first list item, it works fine. Take a look at my code below: <div> <br> <li v-html="`a`"> <ul> <li ...

Unable to display image using jQuery load() function on an HTML page

I have implemented the following code snippet to load an HTML page within a div: $("#htmlViewer").load("conversion_test/to_convert_3264/"+getPageName(pageCount)+".htm", function(response, status, xhr) { if (status == "error") { ...

Creating a dynamic div element in JQuery with a custom error message

In my application, I receive a JSON response from a validation API. The response includes the ID of each input field along with an error message. { "backgroundcolor": "Color is not Supported", "terms" : "Sorry the ...

Enhancing jQuery Inline Row Deletion with a Confirm Modal Box in Bootstrap 3

I have a jQuery function that deletes row data from MySQL. It currently works with jQuery confirm, but I would like to incorporate Bootstrap 3 modal box confirm instead. JS: function deleteBox(id){ if (confirm("Are you sure you want to delete this re ...

I aim to retrieve the names of all directories

I am seeking assistance from seniors in creating a dropdown list of root directories using PHP. I have almost completed the task, but I am facing an issue with not being able to retrieve the root directory. For example, I want all directories like home/ab ...

Verify the form's accuracy prior to transmitting the information through AJAX to the designated resources on Liferay version 7.3.5

Currently, I am in the process of creating a form within Liferay 7.3.5 with a specific goal in mind. This form is designed to validate input data before it is sent via AJAX to designated resources. Despite having functioning code, I am facing an issue whe ...