Wednesday, May 6, 2015

Array Data Population on HTML / JQUERY

JSON ARRAY DATA

{"mydream":[ { "mydreaminfo": [ { "mydream_id": 324, "poster_name": "post112201545438.jpg", "mydream_title": "Non-Stop", "release_year": "2014", "genre": 10, "genre2": 0, "genre3": 0, "description": "An air marshal springs into action during a transatlantic flight after \r\nreceiving a series of text messages that put his fellow passengers at \r\nrisk unless the airline transfers $150 million into an off-shore \r\naccount.", "director": "Jaume Collet-Serra", "producer": "NA", "screenply": "Christopher Roach, John W. Richardson", "cast": "Liam Neeson, Julianne Moore, Lupita Nyongo,Nate Parker, Michelle Dockery, Scoot McNairy, Bar Paly", "rating": "2" } ] }, { "username": [ { "userid": 1, "user_name": "amit", "review_id": 0 } ] }, { "comment": [ { "user_id": -1, "mydream_id": 0, "comment_id": 0, "commentt": "No Comment", "comment_date": null, "review_id": 0 } ] } ]}



JQUERY CODE TO GET DATA

$(document).ready(function() {
  var uidmt=window.localStorage.getItem('mtpwd');
  //var uidmt=1;
  var output = '';
  var out,out1,out2='';
  var movid;
  var id = GetParameterValues('mydream');
  $.getJSON("http://dharamart.blogspot.in/Json_mydreaminfo.aspx?userid="+uidmt+"&mydreamid="+id+"", function(mydata) {
  $.each(mydata.mydream[0].mydreaminfo, function(key, value){   // array )
    movid=value.mydream_id;
var poster=value.poster_name;
    var movtitle=value.mydream_title;
$.getJSON("http://dharamart.blogspot.in/Json_genre.aspx", function(mydata1) {
$.each(mydata1.genrelist, function(key1, value1){
var mid=value1.mydream_type_id;
var mtype=value1.mydream_type;
        if(mid==genre)
        {
out=mtype;
}
});
if(movid==-1){
}
else{
$("#dlinfo_ctl00_Label2").text(desc);
$("#dlinfo_ctl00_lblgen1").text(out);
}
});
});
});


//user review
$.getJSON("http://dharamart.blogspot.in/Json_mydreaminfo.aspx?userid="+uidmt+"&mydreamid="+id+"", function(mydata1) {
$.each(mydata1.mydream[1].username, function(keyun, valueun){
 var userid=valueun.user_id;
 var username=valueun.user_id;
 if(userid==0){
}
else{
  $("#lblname").text(username);
 }
 });
});
 
 
 
//user commenton mydream
$.getJSON("http://dharamart.blogspot.in/Json_mydreaminfo.aspx?userid="+uidmt+"&mydreamid="+id+"", function(mydata2) {
$.each(mydata2.mydream[2].comment, function(keycmt, valuecmt){
var user_id=valuecmt.user_id;
var comment_id=valuecmt.comment_id;
if(user_id==0){
}
else{
output2+="user id="+user_id+" mydream id="+mydream_id+" comment="+commentt+"comment date  "+comment_date+"";
}
});
$(".pnlnot2").html(output2);
});
});

Through this code you will easily get the data from json output doesn't matter data population will on array or without array when you go through this sample code you will suly get the answer of your array problem in JSON using jquery.

With best Complements ....

No comments:

Post a Comment

Dharamart.blogspot.in