我有问题要问你:
$menuID 包含某物的 id,您可以使用它通过该 ID 从表中获取它。这是正确的?
如果正确,您必须将此 ID 传递给 PHP 处理程序页面。
例子:
索引.php:
<script type="text/javascript">
jQuery(function($){
$('h2.editableText, p.editableText').editableText({
newlinesEnabled: false
});
$.editableText.defaults.newlinesEnabled = true;
$('div.editableText').editableText();
$('.editableText').change(function(){
var newValue = $(this).html();
// important code:
$.ajax({
type: "POST",
url: "save.php",
data: { val : newValue, key:$(this).parent().tagName, id:$(this).parent().attr('class')},
success: function(msg){
alert( "Data Saved: " + msg );
}
});
});
});
</script>
和身体部位:
<body>
<div id="wrapper">
<div id="content">
<?php
$isnull = getContent($menuID, "title");
if ($isnull != "") {
echo "<h2 class=\"editableText\"><center><p>" . getContent($menuID, "title") . "</p></center></h2><br>";
} else {
null;
}
?>
<div class="editableText">
<p class="<?php echo $menuID?>"><?php echo getContent($menuID, "maincontent");?></p>
</div>
</script>
<?php
mysql_close($connection);
?>
还有一个,save.php:
<?php
# content that you send from client; you must save to maincontent
$content=$_POST['val'];
# $from=='div' if it from maincontent or $from=='center' if it from title
$from=$_POST['key'];
# id of your post
$id=$_POST['id'];
#here you can save your content;
?>