简体   繁体   中英

window.location.href not working, can't redirect

I've been trying to put a window.location.href to work, but I can't see to make it to redirect my page.

Here is the code:

$('#filtrar').click(function() {
    var pai = document.getElementById("pai");
    var filho = document.getElementById("filho");
    var marca = document.getElementById("pages");

    var value_pai = pai.options[pai.selectedIndex].text;
    var value_filho = filho.options[filho.selectedIndex].text;
    var value_marca = marca.options[marca.selectedIndex].text;

    newLink = 'categorias.php?';
    if ((value_filho != "----") && (value_filho != "selecionar categoria"))
    {
        filho_link = filho.value;
        newLink += "categ=" + filho_link + "&";

    } 
    else if (value_pai != "selecionar categoria")
    {
        pai_link = pai.value;
        newLink += "categ=" + pai_link + "&";
    }

    if (value_marca != "selecionar marca")
    {
        marca_link = marca.value;
        newLink += "marca=" + marca_link + "&";
    }

    newLink = newLink.slice(0, -1);
    window.location.href = newLink;
});

It might not be the case, but I'm also using ajax on this page to refresh one dropdown list that gives data for the refresh.

Thanks

当我在按钮上使用带有post方法的表单时出现了一个问题,因此,它将刷新页面并且不以应有的方式重定向页面

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM