What might be causing the jQuery to not hide this div despite the URL parameter?

I've been trying to animate a page div, but only if the URL includes "?success=true".

Despite attempting various methods (currently placed in the footer), I haven't had any luck.

   <script type="text/javascript">

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                results = regex.exec(location.search);
            return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        }
        if (getParameterByName("success") == "true") 
            $("#success-cover").hide(); 
        });
</script>

This script is affecting:

<div id="success-cover" class="success-cover">
 <div class="success" id="success"><img class="success-logo" src="images/logo-small-new.png">
 </div>
</div>

Am I overlooking something important?

Answer №1

Your if statement contains some syntax mistakes:

    if (checkSuccessParameter() == "true") {
        $("#success-overlay").toggle(); 
    }

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 jQuery to parse XML search results and store them in an array

Earlier, I posed a question and received assistance with code that could extract an XML file from a YouTube search query. With the help of jQuery, I was able to retrieve the necessary information (video ID) from the XML file and store it in a javascript va ...

What is the best approach for testing the TypeScript code below?

Testing the following code has been requested, although I am not familiar with it. import AWS from 'aws-sdk'; import db from './db'; async function uploadUserInfo(userID: number) { const user = db.findByPk(userID); if(!user) throw ...

Tips for showcasing the information of an object on the client side with JSON

public class ProductController : ApiController { Product[] items = new Product[] { new Product { Id = 1, Name = "Banana Bread", Category = "Bakery", Price = 2 }, new Product { Id = 2, Name = "Kite", Category = "Toys", Pri ...

Transforming multi-layered form data into a JSON array structure for seamless integration with application/json

I'm currently developing a Laravel application and facing an issue with the $controller->wantsJson() method in the back-end. This method returns TRUE only if the content type of the request is set to application/json. jQuery.ajax({ type: ...

Menu Similar to Wordpress Admin Interface

Is there a tutorial or jQuery plugin available that can create a menu that collapses both vertically and horizontally? I've searched online but only found options for vertical collapsing menus. The Wordpress option seems to be too integrated for my ne ...

Exploring JS files for bugs using VS Code

Just starting out with learning javascript. Currently trying to troubleshoot this basic code: console.log("Hello World!\n"); // there's a breakpoint here let million = 1_000_000; console.log(million); However, upon hitting the play b ...

Exploring the images in a continuous loop

Looking to create a unique image looping effect using HTML, CSS, and Jquery/Javascript. The concept is to display several images on one page that do not move, but loop through them one at a time while displaying text above the current image. For example, ...

Creating interactive network visualizations using JavaScript

I've been in search of javascript code that can help me create a visual representation similar to this example. Specifically, I need something that can display links between boxes when clicked on or hovered over. I'm still not sure what this par ...

Utilize Bootstrap modal to input information into the DataTables library

I am trying to use a bootstrap modal to insert data, but I am encountering an error on the action index. As a result, the button that I added is not functioning correctly. Can someone please review my code to see if there are any mistakes? User Action Con ...

Failed to retrieve Json data from the designated remote url

I have been trying to figure this out for hours. I'm struggling to retrieve the JSON data from a remote REST API. My goal is to fetch the JSON data and display the "html_url" field from it on my website. <html> <head> ...

Is the utilization of react-router for developing 'single-page applications' causing a depletion of server resources?

Hello, I am relatively new to the world of web development and would appreciate guidance on any misunderstandings I may have. Currently, I am immersing myself in learning the MERN stack. For my practice project, I am aiming to create a simple two-page webs ...

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 ne ...

Hover effects using CSS3 transitions for the content before

Greetings everyone, I apologize for any language barriers. The title may not be clear at first glance, so let me explain what I am attempting to achieve. I have a navigation menu structured like this: <nav> <ul> <li>& ...

It appears that req.session is not defined and the user_id within req.session is not

Currently, I am implementing session management with Express and Node using HTTPS. I am facing an issue where I need to create a session in Express for authentication before redirecting to static files in the public folder. Previously, I encountered a prob ...

Codeigniter not functioning properly with Ajax

I am trying to implement this javascript function $('a[name=deleteButton]').on('click', function () { arr=[]; var arr = $("input[name='post[]']:checked").map(function() { return this.value; }). ...

Manipulating the zoom level of a webpage through HTML tags or javascript

Is there a way to adjust the zoom level of a webpage using HTML or JavaScript? I am trying to display a webpage on Internet explorer 9 with a zoom property set to 85%. ...

Tips for avoiding whitespace in flexbox as you resize an item

My flex box setup is pretty straightforward: main { width: 660px; height: 100%; display: flex; justify-content: center; align-items: center; flex-direction: column; } When I look at my page, it appears like this: https://i.sstatic.net/JF8KC.j ...

Can React components be saved in an array?

I am currently working on enhancing the code snippet provided below. This code is intended to iterate through elements of an array using keys to locate images within a lengthy SVG file directly embedded in the document under the identifier "SomelongUglySVG ...

Converting JSON into a PHP array without relying on json_decode() functionality

Currently, in a project I am working on, I am utilizing jstree with an intention of saving the tree structure to a database. To retrieve the tree data, I'm using the following code snippet: var tmp = $('#tree').jstree(true).get_json(); con ...

What is the best way to export assets into a React Native JS file?

After watching a video on YouTube, I noticed that at 3:20 the individual in the video quickly exported multiple assets into a file without providing any explanation. Can someone please view this specific moment in the video and clarify how this person mana ...