且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用jQuery Ajax显示JSON数据?

更新时间:2023-01-16 10:32:35

您似乎缺少分析JSON以将其转换为数组的行.您的代码应添加以下行:

You seem to be lacking the line to parse your JSON to convert it in an array. Your code should add this line:

...
success: function(data) {
          console.log(data);
          data = jQuery.parseJSON(data); // <-- *** ADD THIS LINE ***
          var html_to_append = '';
          $.each(data, function(i, item) {
            html_to_append += .......