0

url: "index.php/post/get_post", この url は次のような json データを返します...

[{"id":"3","user_id":"2","message":"okiokiokio","is_active":"1","created_at":"2013-05-24 00:00:00","updated_at":"2013-05-24 00:00:00"}]

特定のフィールドのデータを印刷する方法

$(document).ready(function(){
        $.ajax({
                type: "POST",
                url: "<?php echo base_url();?>index.php/post/get_post",
                datatype: 'json',
                success: function(data){
                    $('#divusername').append(data.user_id);       
                }
        });
});
4

2 に答える 2

1

これはあなたを助けるかもしれません。

$(function() {
    $.ajax({ type: "POST", url: "index.php/post/get_post",
        datatype: 'json',
        success: function(data){
            var parsed_data = $.parseJSON(data);
            $('#divusername').html(parsed_data.user_id);
        }
    });
});
于 2013-05-24T13:05:25.273 に答える