2

Once I add the date and time the url should like this become

http://metrobikes.in/api/cities/1/models?start_time=14%3A00&end_time=16%3A00&end_date=2017-10-27&start_date=2017-10-27

I.e. it should load the bikes available at that time

$('#btn-bik-sel').on('click', function() {
  alert("asdada");
  alert($('#datetimepicker2').val());
});


function available() {
  var date = $('#datetimepicker2').val();

  $.ajax({
    url: 'http://metrobikes.in/api/cities/1/models?',
    method: "GET",
    data: {
      'start_time': start_time,
      'end_time': end_time,
      'end_date': end_date,
      'start_date': start_date
    },
  }).done(function(data) {
    for (var i = 0; i < data.result.data.length; i++) {
      console.log(data);
    };
  });
};
<div class="col-xs-6">
  <input type="text" class="form-control date-time" id="datetimepicker2" placeholder="Start date">
  <input type="text" class="form-control date-time" id="datetimepicker1" placeholder="Start time" style="margin-top: 10px">
</div>

<div class="col-xs-6">
  <input type="text" class="form-control date-time" id="datetimepicker21" placeholder="End date">
  <input type="text" class="form-control date-time" id="datetimepicker111" placeholder="End time" style="margin-top: 10px">
</div>

<div class="col-xs-12 text-center" style="margin-top: 10px;">
  <button class="btn btn-primary" id="btn-bik-sel">Continue</button>
</div> 
3
  • Where are you setting start_time, end_time etc...? Commented Oct 27, 2017 at 9:46
  • its an input field where user can enter any start and end date and time Commented Oct 27, 2017 at 9:49
  • Yes, but where are you setting those JS variables? They don't magically set the values without you writing some code to do it Commented Oct 27, 2017 at 9:59

2 Answers 2

2

try to change your data section to this:

...
data: {
      'start_time': $('#datetimepicker1').val(),
      'end_time': $('#datetimepicker111').val(),
      'end_date': $('#datetimepicker21').val(),
      'start_date': $('#datetimepicker2').val()
    },
Sign up to request clarification or add additional context in comments.

1 Comment

and after that? if i click the button ill get the desired result?.
0

You are not setting values to start_time, end_time, start_date and end_date. They don't magically set the values without you writing some code to do it. You can get those values using

$('#your-id').val();

1 Comment

If this answer is useful please accept my answer @Syed Tabeeb

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.