Redirect if QueryString exists

Redirect if QueryString exists

Hi,

I am using below code. It works fine when no url query string but when url query string is specified then it's just reloading the same page with  no error in google console.

can you help please..

  1. success: function()
  2. {
  3. if (window.location.href.search("[?&]url=") != -1) { window.location.href = redirect; }
  4. else window.location.href = 'index.php';
  5. },