skip to Main Content

How to redirecting to a new page after closing popup window with code like this:

     send_ajax_formdata("POST","{{ url('/url') }}", {}, fData, {})
     .then((resp) => {
        if(resp[0].valid == "true") {
             success_alert(resp[0].message);
        }else {
            warning_alert(resp[0].message);
        }

        elem.removeClass("disabled");
        elem.html(text);
    })
    .catch((err) => {
        danger_alert(err.message);
        elem.removeClass("disabled");
        elem.html(text);
    })

When button close clicked then it will close the popup window with script disabled removeClass. But instead back to page where that popup window page exist, I want to redirecting it to a new page. How to do that?

2

Answers


  1. you use window location to redirect to url in jquery.

    window.location.href = '/' + resp.data.redirect_path;
    

    Here, resp.data.redirect_path is your redirect url variable, you can also use solid url to any page like:

    window.location.href = "http://www.google.com";
    
    Login or Signup to reply.
  2. You can use location.replace

    window.location.replace(resp.href);
    
    // let say the href is "https://stackoverflow.com/"
    window.location.replace("https://stackoverflow.com/");
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search