您好,我想从一个输入字段读取文本值,然后在 JQUERY 函数中使用它从数据库获取数据我希望像这样填充源:/search/batch_name_by_barnID/1,但输出类似于:/batch_name_by_barnID?项=1
我如何设置这部分:source: "/search/batch_name_by_barnID/"+$('#barn_id').text(),以获得像 /search/batch_name_by_barnID/{number} 而不是 /search/batch_name_by_barnID?term 的输出? =1
我的 HTML 是:
<input type="text" class="form-control search_occupied_barn_name" placeholder="Type here ..." name="barn_name">
<span class="help-block search_occupied_barn_name_empty" style="display: none;">No Results Found ...</span>
<input type="text" class="search_barn_id" name="barn_id" id="barn_id">
<label>باتش</label><br>
<input type="text" class="form-control search_batch_name_barn" placeholder="Type here ..." name="BatchName">
<span class="help-block search_batch_name_barn_empty" style="display: none;">No Results Found ...</span>
<input type="text" class="search_batch_id" name="batch_id" id="batch_id">
我的 JQUERY 是:
$( ".search_batch_name_barn" ).autocomplete({
source: "/search/batch_name_by_barnID/"+$('#barn_id').text(),
minLength: 1,
response: function(event, ui) {
if (ui.content.length === 0) {
$(this).parent().addClass('has-error');
$(this).next().removeClass('glyphicon-ok').addClass('glyphicon-remove');
$(".search_batch_name_barn_empty").show();
$('.form_submit').hide();
} else {
$(".search_batch_name_barn_empty").hide();
$('.form_submit').show();
}
},
select: function(event, ui) {
$('.search_batch_id').val(ui.item.id);
$('.search_batch_name_barn').val(ui.item.value);
}
});
catspeake