Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

266
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!