Handle ajax request returned data with Jquery

Asked

Viewed 458 times

3

My request:

 $.post(
      "http://painel.thomerson.com.br/imagens/escolher-template",
      $(this).serialize(),
      function(data){
            $("#Resultado").html(data);
      }
 );

What is happening is that by inserting the contents of the variable data à div #Resultado, is being inserted the full html code of the page itself, I wonder if there is any way to return another type of data.

Screen before Ajax request:

inserir a descrição da imagem aqui

Screen after Ajax request:

inserir a descrição da imagem aqui

There was duplication of the whole script :/

I saw some examples that returned data on JSON, bringing only what is necessary for manipulation, but I could not understand very well how it was done, I hope to have been clear, otherwise, comment and I will edit what is necessary.

  • What are you trying to get? JSON, html or xml? What is the purpose of this request? It is not clear what you are trying to do.

1 answer

3


If you are making the same request for the page you are, ajax when complete and return the data it will return all the content from the same screen, causing the content of your page to duplicate

  • So man, I realized this, this was my mistake, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.