duanrenzou1619 2014-08-20 13:31
浏览 97
已采纳

JQuery $ .ajax请求json响应

A JSON returned as response to this request is not recognized.

request = $.ajax({
        url: "form_handler.php",
        type: "post",
        dataType: "json",
        data: serializedData
});

The php code in form_handler.php which returns the response:

if ($success) {
    echo json_encode(array("success"=>"false"), JSON_PRETTY_PRINT); 
}
else
{
    echo json_encode(array("success"=>"true"), JSON_PRETTY_PRINT); 
}

And thus in:

request.done(data) 
{
    alert(data.success);     // error: cannot read property of 'success' of null 
}
  • 写回答

4条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 hdfs在idea上传文件运行错误
      • ¥15 关于selenium网页闪退
      • ¥15 怎么用PYTHON解类似于x = y+zx + cy = x+zy + v的方程
      • ¥300 FLASH AS2.0制作一个类似手机上下滑动一样的效果
      • ¥15 为什么使用openFoam 中的icoFoam计算圆柱扰流时出现浮点数例外(核心已转储)
      • ¥15 51单片机外部中断控制数码管
      • ¥15 创建网页里面的图片显示不出来
      • ¥15 语音控制的编写?(语言-c#)
      • ¥15 matlab输入书上的代码运行错误
      • ¥15 matlab怎么做三维曲面