Javascript JSON响应正常的Jquery Post

Javascript JSON响应正常的Jquery Post,javascript,php,jquery,json,Javascript,Php,Jquery,Json,我在一个PHP页面上发布了一篇jQuery帖子,其中包含一个JSON响应。它成功地生成了JSON,因为我让它显示整个响应。但是,在每一天,我都不能让它发出警报。任何想法都值得赞赏。非常感谢。JSON看起来像: [{"Part_Field":"Part_Note:3","Part_Value":"ValueofPart"},{"Part_Field":"Ft_In:3","Part_Value":"12"}, ... jQuery: $.post('/scripts/update_detail

我在一个PHP页面上发布了一篇jQuery帖子,其中包含一个JSON响应。它成功地生成了JSON,因为我让它显示整个响应。但是,在每一天,我都不能让它发出警报。任何想法都值得赞赏。非常感谢。JSON看起来像:

[{"Part_Field":"Part_Note:3","Part_Value":"ValueofPart"},{"Part_Field":"Ft_In:3","Part_Value":"12"}, ...
jQuery:

 $.post('/scripts/update_detail.php' , field_id + "=" + value, function(data){
              var d = document.getElementById("displayjson");
                d.innerHTML = data;

               $.each( data, function( key, value ) {
                  alert( value.Part_Field );
                });


   });

您忘记了字符串
},“json”)最后

更正后的代码应为:

 $.post('/scripts/update_detail.php' , field_id + "=" + value, function(data){
              var d = document.getElementById("displayjson");
                d.innerHTML = data;

               $.each( data, function( key, value ) {
                  alert( value.Part_Field );
                });


   },"json"); // Here, you need to tell jQuery that whatever response
// we are getting from server is a JSON string, in your case, 
//it was considering it as a string.

你确定jQuery知道它是JSON吗<代码>控制台日志(数据类型)是否显示字符串?
console.log(数据)
,查看它是字符串还是数组。除非
内容类型
标题是
application/json
,否则它可能是一个字符串。谢谢,它是一个字符串。我必须对一个新变量的数据运行jQuery.parseJSON。谢谢你的帮助!