我正在使用阿罗哈编辑并喜欢它.
我坚持将页面上不同div的数据保存到数据库.
我找到了一个名为contentEditable的教程:http://gazpo.com/2011/09/contenteditable/
它将1 div保存到数据库,但是我的网页上有多个div,我无法计算出逻辑.
如果你能提供帮助,我真的很感激?
我的index.php上有以下php/Javascript/Ajax:
<?php
//get data from database.
include("db.php");
?>
<script>
$(document).ready(function() {
$("#save").click(function (e) {
var content = $('[class^="editable"]').html();
$.ajax({
url: 'save.php',
type: 'POST',
data: {
content: content
},
success:function (data) {
if (data == '1')
{
$("#status")
.addClass("success")
.html("Data saved successfully")
.fadeIn('fast')
.delay(3000)
.fadeOut('slow');
}
else
{
$("#status")
.addClass("error")
.html("An error occured, the data could not be saved")
.fadeIn('fast')
.delay(3000)
.fadeOut('slow');
}
}
});
});
$('[class^="editable"]').click(function (e) {
$("#save").show();
e.stopPropagation();
}); …
Run Code Online (Sandbox Code Playgroud)