Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery add URL parameter [duplicate]

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?

like image 588
Legend1989 Avatar asked Aug 31 '15 18:08

Legend1989


1 Answers

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;
  });
like image 193
Leo Javier Avatar answered Oct 19 '22 07:10

Leo Javier