Reputation: 576
url: "index.php/post/get_post", this url return json data like...
[{"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"}]
How to print data in particular fields
$(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);
}
});
});
Upvotes: 0
Views: 13563
Reputation: 1887
This may help you.
$(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);
}
});
});
Upvotes: 1