JSON文件不会将值返回到html部分?

时间:2017-12-05 15:10:04

标签: javascript html json

<?php
$data= file_get_contents('blogData.json');
echo($data);
?>

========下一节==========

<?php
    $data= file_get_contents('blogData.json' , true);
    $decodedData= json_decode($data, true);
    $countID = count((array)$decodedData) + 1;
    $decodedData[$countID] = array('id' => $countID, 'title' => $_POST['postTitle'], 'author' => $_POST['postauthor'], 'desc' => $_POST['postdescription'], 'post' => $_POST['blogPost']);
    file_put_contents('blogData.json' , json_encode($decodedData));
    console.log($decodedData);
    header('Location:Blog.php');
?>

===========================

<script type="javascript/text">
$.getJSON("proxy.php", function(data) {
    $.each(data, function(index, entry) {
        console.log(entry);
        $('#posts').append('<h3>' + entry.id + '</h3>');
        $('#posts').append('<h4>' + entry.author + '</h4>');
        $('#posts').append('<h4>' + entry.desc + '</h4>');
        $('#posts').append('<h4>' + entry.post + '</h4>');
    })
});
</script>   

我试图将JSON文件返回到博客帖子中,不知道为什么他们不会返回? 我希望博客文章显示在空白的红色框中 result

0 个答案:

没有答案