Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda