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

113
Vistas
echoing the text message from textarea via PHP and AJAX jQuery

HTML:

   <div class="mb-3">
       <label for="comment" class="form-label">Comments</label>
       <textarea class="form-control" id="comment" name="comment" rows="3"></textarea>
   </div>

javascript:

let comment = $('textarea.msg').val()
alert(comment);

and then PHP:

echo $_POST['comment'];
echo isset($_POST['comment']);
echo trim($_POST['comment']) != '';

Here, the Response tab in Network tab of Firefox Inspect shows nothing for the echo commands in PHP. I am not sure why the textarea input hi is not shown hence not inserted.

Even for the javascript alert of comment variable, I get this:

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

 let comment = $('#comment').val().trim();

Credits to Chris Haas.

about 4 years ago · Juan Pablo Isaza Denunciar

0

<div class="mb-3">
   <label for="comment" class="form-label">Comments</label>
   <textarea class="form-control" id="comment" name="comment" rows="3"></textarea>
</div>

id is unique in the HTML and with jquery it would be easier to target the element you want. For class we use $(.<classNAME>) while for id we use $(#<id_Name>)

Your Case, $('#comment').val()

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