Redirect to Tab specifies [closed]

-3

Good morning, I have a tab where I have a form that is sent via Ajax to my controller and I want it after the Ajax response the person is redirected to another tab after reloading the page, I need to click on calculate a person go to Analysis Results Can anyone give me a light?

TABcode:

<ulclass="nav nav-tabs border-0 pt-5 data pt-sm-5 pt-md-1 mt-4 justify-content-center position-fixed mt-md-2 col-sm-12 col-md-12 ml-0 " style="z-index:1;font-size:100%;" id="myTab" role="tablist">
    <li class="nav-item data active">
        <a class="nav-link data active " id="data" data-toggle="tab" href="#DataInput" role="tab" aria-controls="Data Input" aria-selected="true">Data Input &nbsp; <i class="fa fa-angle-right"></i></a>
    </li>
    <li class=" bg-light ">
        <input class="button" onclick="calculate()" type="submit" name="" 
     value="Calculate" style="margin-top:5px;">&nbsp;
    </li>
    <li class="nav-item analise ">
        <a class="nav-link  analise" id="analise" data-toggle="tab" 
       href="#Analise" role="tab" aria-controls="Analysis Results " aria- 
       selected="true"><i class="fa fa-angle-right"></i>Analysis Results 
      &nbsp; </a>
    </li>
    <li class="nav-item ">
        <a class="nav-link " id="graphs" data-toggle="tab" href="#Graficos" 
      role="tab" aria-controls="Analysis Results " aria-selected="true"><i 
       class="fa fa-angle-right"></i>Graph &nbsp; </a>
    </li>

</ul>
    
asked by anonymous 11.12.2018 / 12:56

3 answers

1

My problem has been solved as follows:

<a href="#" id="meuElemento" onclick="funcao('minha string')">clique aqui.</a>

    <script>
        function funcao(string) {
            alert(string)
        }
        document.getElementById("meuElemento").click();
    </script>
    
13.12.2018 / 15:36
1

Use window.location.href = "http://seusite.com";

After your Ajax response

    
11.12.2018 / 12:59
1

I do not know if I understand correctly but try this: In the .done(... part of the ajax method after you redirect to that page.

if ($('#tabCalc').hasClass('show')) { // verifica se a tab esta sendo 
mostrada
  $('#tabCalc').removeClass('show'); // remove a class show da tab
  $('#tabAna').addClass('show');     // add Class show na tab desejada
}
// ou você pode tentar assim mais simples poem ao meu ver uma forma 
ruim ou vc verifica todas com if acimae faz isso :D
  $('#tab1').removeClass('show');
  $('#tab2').removeClass('show');
  $('#tab3').removeClass('show');
  $('#tab4').removeClass('show');
  $('#tabDesejada').addClass('show'); 

After editing the question new options can be seen as in the code below:

// Após o retorno do método Ajax para redirecionar para o local da pagina desejado
window.location.href = "http://index.html#Analise"; 
// ou forçar um click no elemando analise que tbm o levará para o local desejado
document.getElementById('analise').click();

There are probably better ways to do this. I hope this helps you now. because from what I understood the question was what you wanted

    
11.12.2018 / 15:52