Answer the question
In order to leave comments, you need to log in
Save value contenteditable="true" + ajax + php. How?
Good afternoon.
Don't be too harsh, I'm new.
Is it possible to store the contenteditable="true" value via ajax in one index.php file, or is an additional file like obrabotka.php required?
Something like:
<?php
$a = $_POST['txt'];
?>
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
</head>
<body>
<div id="main" contenteditable="true">Привет</div>
<p id="xx"></p>
<p><?php echo $a; ?></p>
<script type="text/javascript">
$( document ).ready(function() {
$("#main").blur(function(){
$.ajax({
type: 'POST',
url: 'index.php',
data:txt=$("#main").text(),
success:function(){
$("#xx").html($("#main").text());
}
});
});
});
</script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
It's possible, I'll allow it.
<php?
if (!empty($_POST['txt'])) {
// здесь проверки, сохранение, вот это всё
}
,,,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question