12

I have a jquery multiple drag and drop file uploader using dropzone.js.

I have added the following code to the dropzone code

  this.on("queuecomplete", function (file) {
      alert("&success=yes");

  });

So when the queue has completed it sends an alert at the moment however I want to change it so it so that using jquery it adds this as a parameter to the URL.

Any ideas how to do this using jquery?

2
  • 1
    I'm guessing you want to add the parameter to the current page's URL and reload the page with the URL plus the parameter. Is this the real question? Commented Aug 31, 2015 at 18:35
  • This is jQuery specific. The duplicate question is javascript specific, and has no jquery tag. Commented Mar 1, 2019 at 14:40

1 Answer 1

41

This will do the job...

this.on("queuecomplete", function (file) {
      var url = document.location.href+"&success=yes";
      document.location = url;
  });

Option two (in case you already have one parameter)

this.on("queuecomplete", function (file) {
    if(document.location.href.contains('?')) {
        var url = document.location.href+"&success=yes";
    }else{
        var url = document.location.href+"?success=yes";
    }
      document.location = url;
  });
Sign up to request clarification or add additional context in comments.

8 Comments

...unless there's no ? in the URL.
that's a quick fix... give a sec
I would recommend to use an standard URI/URL manipulation library for this, e.g. medialize.github.io/URI.js
@LeoJavier, looks like MDN recommends .includes instead of .contains anyhow.
The question asks for jQuery solution, this uses no jQuery.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.