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

162
Visualizações
Dangers of client-side HTML generation from AJAX JSON response?

So I'm having a website which uses a couple of AJAX requests which fetch data from the DB in an array in PHP, and then generate the markup accordingly needed on the frontend within PHP, then deliver that to the client, and insert it into the DOM using js (simple targetElement.innerHTML = responseFromServer principle).

What I want to do now to be more compatible with non-web interfaces (such as ios and android apps) is adapt these AJAX calls to exclusively output JSON responses. And consequently change the js client-side code to generate the according markup upon reception, with stuff like createElement(), appendChild(), etc. In this case, some people told me that this could be dangerous, in terms of the security of the webapp. I could not understand these reasons; so what are the risks of generating HTML content on the client-side in js, using a JSON response, instead of directly inserting a thus on-the-server-generated-HTML into the DOM?

about 4 years ago · Juan Pablo Isaza
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