Skip to content Skip to sidebar Skip to footer

How To Display Json In Html

I am trying to display JSON data that I retrieve from an ajax call but I am unable to display any data. This my function: function runbiosis(){ var url = site_url+'Biodata/runbio

Solution 1:

Your JSON data is an array with a single element but in your runbiosis function you are trying to access the property of an object, not an element of an array.

Can you try this - note it is the same code but you are getting the jk property of the first (and only) element of the array that is returned:

functionrunbiosis(){
  var url = site_url+"Biodata/runbiosis";
  $.getJSON(url,function(data) {
    $('#jk').val(data[0].jk);
    $('#agama').val(data[0].agama);
   });
};

Post a Comment for "How To Display Json In Html"