javascript - Uncaught TypeError: Cannot read property 'HotelInfo' of undefined -
//an ajax call api jquery(document).ready(function() { jquery.ajax({ url:"http://localhost:8080/activitieswithrealdata?location=%22sea%22&startdate=%2205-14-16%22&enddate=%2205-16-16%22&theme=%22food%22", datatype: 'json', type: 'get', success: function (data) var viewmodel; if(data) { viewmodel = new dealspagemodel(data); var idlist = ""; (var = 0; i< data.packagedeal.length; i++) { if (i == data.packagedeal.length -1) { idlist += data.packagedeal[i].hotelid; } else {idlist += data.packagedeal[i].hotelid + ','; } } var searchurl = "http://terminal2.expedia.com/x/hotels?hotelids=" + idlist + "&apikey=6wev4ksgij5eqhd58o2xtdwvo35lzf2s"; //another call api return hotel specific info jquery.get(searchurl, function ( ) { for(var i=0; i<viewmodel.deallist.length; i++) { var hotelid = viewmodel.deallist[i].hotelid; for(var i=0; i<data.hotelinfolist.hotelinfo.length; i++) { var url = hotelinfolist.hotelinfo[i].thumbnailurl; var name = hotelinfolist.hotelinfo[i].name; } // hotelid current deal // loop through hotelinfolist.hotelinfo , find out url hotel idlist //loop through hotelinfolist.hotelinfo , find out name hotel viewmodel.deallist.push(new deal(data.packagedeal[i], url, name)); } ko.applybindings(viewmodel); }); } } }) });
you loop through data.hotelinfolist.hotelinfo
operate on hotelinfolist.hotelinfo[i].thumbnailurl
. data.
@ beginning missing.
also, place data
in callback function in jquery.get
:
jquery.get(searchurl, function(data){ // …
Comments
Post a Comment