为什么JavaScript不能识别PHP的输出?

ber*_*436 -6 javascript php jquery

我有jQuery在PHP上发帖子,像这样:

$.post("/contact/edit_contact", serialized).done(
    function(response) {
        if (response.success) {
            $('#row-' + id).html(response.html); 
        } else {
            alert("There was a problem saving");
        }
Run Code Online (Sandbox Code Playgroud)

处理它的PHP返回此响应(在网络选项卡中):

<div> 
    A bunch of HTML...
</div>

Warning: Cannot modify header information - headers already sent by (output started at /.../contact.controller.php:56) in /.../include/App.class.php on line 82

Call Stack:
    0.0005     683376   1. {main}() pathTo/index.php:0
    ....       
     pathTo/contact.controller.php:58
    0.6205    6286496   6. header() pathTo/App.class.php:82

{"success":true,"html":"<div>\n .... </div>"} 
Run Code Online (Sandbox Code Playgroud)

但当我这样做时,console.log(response.success)我得到"未定义".

为什么JavaScript/jQuery承诺没有看到response.success设置为true?

Mar*_*pel 6

因为在JSON格式的字符串之前有很多东西.

为什么在JSON字符串之前输出HTML(并尝试修改标题)?