Php .txt文件更新后未加载页面
我正在尝试创建一种在前端更新我的站点的方法。我使用php代码添加了以下内容可编辑区域,以加载.txt文件的内容:Php .txt文件更新后未加载页面,php,jquery,ajax,Php,Jquery,Ajax,我正在尝试创建一种在前端更新我的站点的方法。我使用php代码添加了以下内容可编辑区域,以加载.txt文件的内容: <div class="content" contenteditable="true"> <?php //echo file_get_contents("test.txt"); $file = dirname(__FILE__).'/siteContent/'. $_GET["page"]. '.txt'; $con
<div class="content" contenteditable="true">
<?php
//echo file_get_contents("test.txt");
$file = dirname(__FILE__).'/siteContent/'. $_GET["page"]. '.txt';
$content = file_get_contents( $file );
$content = stristr( $content, null );
if($content != ""){
echo utf8_encode( $content );
}else{
echo "Empty page. Please erase this text and replace with your own.";
}
?>
使用以下ajax和php代码更新文件后,网站上的内容不会发生更改。即使在一次重装之后。我仍然看到旧的内容。不知道为什么--当我看到.txt文档的内容时,我确实看到它们被更改了
阿贾克斯:
<script>
$('.content[contenteditable=true]').on('blur',function(){
var data = $( "div.content" ).html();
var pageEdit = <?php echo '"'. $_GET["page"] . '"'; ?>;
$.ajax({
url: 'process/edit.php',
type: 'POST',
data: { data: data, pageToEdit: pageEdit },
success: function(result) {
alert('the data was successfully sent to the server');
console.log(pageEdit);
}
});
});
</script>
$('.content[contenteditable=true]')。在('blur',function()上{
var data=$(“div.content”).html();
var pageEdit=;
$.ajax({
url:'process/edit.php',
键入:“POST”,
数据:{data:data,pageToEdit:pageEdit},
成功:功能(结果){
警报(“数据已成功发送到服务器”);
console.log(pageEdit);
}
});
});
PHP edit.txt文件(记住它可以正常工作):
我不知道这里会发生什么。提前谢谢
Atlante A.我的错,在发布之前我没有正确地看到它,但这段代码让事情变得非常糟糕:
$content = stristr( $content, null );
移除它可以使它正常工作。如果有人能解释为什么我会很感激
$content = stristr( $content, null );