lundi 30 octobre 2017

how to display json data related to one id

so, ive written a code for which i need to get locations of that current bike, instead, i am getting the all locations

this is the api "http://ift.tt/2gNLjis"

i wanna display the locations at which that particular bike is available in the select box....

but i am getting all the locations irrespective of the bike...

function available(id){

      $.ajax({
        /*url:'http://ift.tt/2zJDXnw',*/
          url:'http://ift.tt/2hfMqb8'+id+'/models',
        method:"GET",
        data : {
            'start_time': $('#datetimepicker1').val(),
            'end_time': $('#datetimepicker111').val(),
            'end_date': $('#datetimepicker21').val(),
            'start_date': $('#datetimepicker2').val()
        },


    }).done(function(data){
          for (var i=0; i<data.result.data.length; i++){

            var available_location = data.result.data[i].available_locations;

                for(j=0; j<available_location.length; j++) {
                    console.log(available_location[j].area);
                    var options = $(".selectionBike");

                    $.each(data, function() {
                        options.append('<option>'  + available_location[j].area +  '</option>');

                    });



              $('.bike-imgs ').append(
                  '<div class="bike-imgs-inner col-xs-12">'+
                  '<img class="bike-in" style="width:100%" src="'+data.result.data[j].image.full+'" />' +
                  '<div class="col-sm-8 col-md-8 col-xs-6"><div class="selected-bike-s1">'+data.result.data[j].name+'</div></div>' +
                  '<div class="col-sm-8 col-md-8 col-xs-6"><div class="selected-bike-loc">'+data.result.data[j].available_locations[0].area+'</div></div>'+
                  //'<div class="col-xs-12 bike-price"> '+data.result.data[i].totalPrice+'  </div>' +
                  '<div class="col-xs-12 bike-price text-center"><select  class="selectionBike form-control"><option>'+available_location[j].area+'</option></select> </div>' +
                  '<div class="col-xs-12 bike-price text-center"> <p> '+data.result.data[i].available_locations[j].price[0]+' </p>  </div>' +
                  '<div class="col-xs-12 bike-price text-center"> <p> '+data.result.data[i].available_locations[j].price[1]+' </p>  </div>' +

                  '</div>'
              );

                }




          };


    });
};



Aucun commentaire:

Enregistrer un commentaire