0

I am trying to initialize some jQuery to only run if a specific querystring is found. However I am having trouble matching the querystring in an IF statement. My code is below.

$(document).ready(function(){
        if($(window.location.search == '?uploaded=success')){
            alert('test has worked');
        }
    });

At the minute this if statement is being ran whether ?uploaded=success is there or not. Can anyone help shed some light on this?

2 Answers 2

2
    if($(window.location.search == '?uploaded=success')){

should be

    if(window.location.search == '?uploaded=success'){
Sign up to request clarification or add additional context in comments.

Comments

0
if($(window.location.search == '?uploaded=success')){...!?

You mean:

if (window.location.search == '?uploaded=success')

or:

if ($(window.location.search) == '?uploaded=success') {

1 Comment

I'm not so sure about that last one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.