Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
content gets hidden while using ajax

I am using ajax for fetching records using following code.

<html>
<head>
<script>
$(function() {
    $('.go-btn').on('click', function() {
        var selected = $('#my-dropdown option:selected');
            $.ajax({    //create an ajax request to load_page.php
        type: "GET",
        url: "boxplot.html",             
        dataType: "html",   //expect html to be returned                
        success: function(response){                    
            $("#responsecontainer").html(response); 
            //alert(response);
        }

    });
        //alert(selected.val()); 
    });
});
</script>
</head>
<body>

some text
<button class="go-btn" type="submit">Go</button> 
<div id="responsecontainer">
<br><hr><br>
<h2>PCA Plot Distribution:</h2><br>
</body>
</html>

In the above code, content page gets loaded on clicking button (at ) but anything after this gets disappeared. How can i fix this issue?

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Because you are setting your response to whole div. Fix your html such that

<div id="responsecontainer"></div> 
<div>
<br><hr><br>
<h2>PCA Plot Distribution:</h2><br>
</div>

So you are settings your response to responsecontainer and rest remains same.

about 4 years ago · Santiago Trujillo Relatório

0

You haven't closed your div in the HTML in the bottom

about 4 years ago · Santiago Trujillo Relatório

0

You just have to close that #responsecontainer div.

var response = "my Response";
$("#goButton").on("click", function(){
  $("#responsecontainer").html(response);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<body>

some text
<button class="go-btn" type="submit" id="goButton">Go</button> 
<div id="responsecontainer"></div>
<br><hr><br>
<h2>PCA Plot Distribution:</h2><br>
</body>
</html>

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda