below json data received ajax response.
{ "error": { "errorcode": "0001", "errortext": "success" }, "responselist": [ { "count": 2, "event": [ { "startdate": null, "eventid": 1234, "eventname": "interview", "modifieduser": "user", "eventtypecode": "1", "eventvenue": null, "eventspecialinst": "isnsdf", "eventstatuscode": "op", "eventlangcode": "eng", "eventdesc": "sdfsadfsd", "fromemailid": "abcd@apple.com", "rsvpdeadline": 5, "canceledind": "yes", "canceldemailtext": "sdfasdfasdfasfasdfasdfasdf", "daystowaitlistlastcall": 5, "daystoreminderadmin": 6, "daystoreminderevent": 3, "daystoreminderinvitation": 2, "enddate": null, "venueaddrline1": null, "venueaddrline2": null, "venueaddrline3": null, "citycode": null, "statecode": null, "appid": null, "modifieddate": "2010-12-16", "countrycode": null, "zipcode": null, "user_id": null, "updateflag": "r" }, { "startdate": null, "eventid": 4321, "eventname": "seasonal hiring", "modifieduser": "user", "eventtypecode": "1", "eventvenue": null, "eventspecialinst": "isnsdf", "eventstatuscode": "op", "eventlangcode": "eng", "eventdesc": "sdfsadfsd", "fromemailid": "abcd@apple.com", "rsvpdeadline": 5, "canceledind": "yes", "canceldemailtext": "sdfasdfasdfasfasdfasdfasdf", "daystowaitlistlastcall": 5, "daystoreminderadmin": 6, "daystoreminderevent": 3, "daystoreminderinvitation": 2, "enddate": null, "venueaddrline1": "kfc", "venueaddrline2": "the forum", "venueaddrline3": "koramangala", "citycode": "bangalore", "statecode": "karnataka", "appid": null, "modifieddate": "2010-12-16", "countrycode": "india", "zipcode": "560040", "user_id": null, "updateflag": "r" } ] } ] }
using below code extract information inside event object. not able it. need guidance.
$.ajax({ url:"<%=request.getcontextpath()%>/service/showinvitedevents/21", datatype:"json", success: function(jsondata) { alert("inside response success"); $.each(jsondata.responselist.event,function(i,item) $.each(employees,function(i,item) { alert('iteration is' + i); var teventname = item.eventname; var teventvenue = item.eventvenue; var tstartdate = item.startdate; var tenddate = item.enddate; var tstarend = tstartdate +" - "+ tenddate ; $("#eventtable tbody").append("<tr><td><a id="+teventname+i+" href=<%=request.getcontextpath()%>/service/session/1234>"+teventname+"</a></td><td>"+teventvenue+"</td><td>"+tstarend+"</td></tr>"); });
first of can't loop on jsondata.responselist.event. jsondata.responselist array either need make double loop or if know there 1 , 1 item in responslist loop on jsondata.responselist[0].event
for rest of i'm not sure why have row:
$.each(employees,function(i,item)
looks misstake isn't valid there(the syntax wrong , hides both , item real each).
Comments
Post a Comment