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

269
Visualizações
ContentEditable doesn't allow to send php strings

I have a problem with contenteditable .

Before i used textarea for sending posts for text. I want to change it now to use contenteditable.

So contenteditable doesn't allow to send php strings from data. For example

DEMO

In this demo i will show you my html and ajax codes. That is working perfectly, if user send normal text. But if user want to share php codes from his friends like (<?php echo 'Hi There.';?>) then problem will be come here. If user write normal text like (Hi There.) then not have any problem.

Normaly we are using val(); if we use textarea like this

var updateText = $('#post-text-area').val();

I think problem will be come here but i am not sure.

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

0

use with encodeURIComponent() .it will prevent the tag's passing from html to php .And retrieve the data from php use with decodeURIComponent()

$(document).ready(function() {


      $("body").on("click", ".sendPost", function() {
        var updateText = $('#post-text-area').html();
        var dataString = 'update=' +  encodeURIComponent(updateText);
        $.ajax({
          type: 'POST',
          url: '/posttext.php',
          data: dataString,
          beforeSend: function() {},
          success: function(html) {
           decodeURIComponent(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