Shorty Shorty - 27 days ago 9
MySQL Question

How to send contenteditable value in td with php

I have the following code in my page:

echo "<td style='border-bottom:1px solid #FFA500;' contenteditable='true'>".$result['body']."</td>";


And I want to send the edited content to mysql_query.

do I simply have to add id to
<td>
and use ajax??

Answer Source

EDIT: Please check the following question for more information, references and helpful answers: How to save and retrieve contenteditable data


Yes, you have to use AJAX to store the edited content, or use a script that generates (hidden) input fields and submits a form with the edited values.

Ready more about contenteditable here (particularly 'Storing the changes'): http://html5doctor.com/the-contenteditable-attribute/#storing-changes

It gives you a JS Bin code snippet where it shows an example how you could send the data to the server using jQuery's $.ajax. It does it on keydown event however, and to save requests, I would suggest doing it on blur.