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

317
Visualizações
Refresh Div's content after AJAX form submission

I have this Ajax code to submit a PHP form. The code works, however I would like the <div> that the content is supposed to change to refresh without the whole page refreshing.

The div's ID is #container.

Here is the AJAX code:

$('.accept_friend').submit(function(){
        var data = $(this).serialize();

        $.ajax({
            url: "../accept_friend.php",
            type: "POST",
            data: data,
            success: function( data )
            {
               //here is the code I want to refresh the div(#container)

            },
            error: function(){
                alert('ERROR');
            }
        });

        return false;
    });
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You will have to change the DIV's innerHTML property.. with jQuery it is done like so:

$('#container').html('... new content goes here...');

so in your case add in the success function:

$('#container').html(data);

or

$('#container').html(data.someAttribute);

depending on the type and structure of your returned data.

over 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