gpt4 book ai didi

javascript - 从输入框使用jquery在ajax中传递参数

转载 作者:行者123 更新时间:2023-11-29 21:00:07 28 4
gpt4 key购买 nike

一旦我添加了日期和时间,url 应该变成这样

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

即它应该加载当时可用的自行车

$('#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>

最佳答案

尝试将您的 data 部分更改为:

...
data: {
'start_time': $('#datetimepicker1').val(),
'end_time': $('#datetimepicker111').val(),
'end_date': $('#datetimepicker21').val(),
'start_date': $('#datetimepicker2').val()
},

关于javascript - 从输入框使用jquery在ajax中传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46972093/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com