将 html 形式的参数添加到 jquery 字符串
adding parameter from html form to jquery string
我正在尝试添加到 javascript 中的以下异步调用,它发送参数 q=<query>
,第二个参数 l=<lquery>
,但我没有看到它发送出去,已检查在开发工具控制台中
var searchbox = $('input#search');
var langquery = $('input#fav_language');
var timer = 0;
// Executes the search function 250 milliseconds after user stops typing
searchbox.keyup(function () {
clearTimeout(timer);
timer = setTimeout(search, 250);
});
async function search() {
// Clear results before searching
noresults.hide();
resultdiv.empty();
loadingdiv.show();
// Get the query from the user
let query = searchbox.val();
// Only run a query if the string contains at least three characters
if (query.length > 2) {
let lquery = langquery.val();
// Make the HTTP request with the query as a parameter and wait for the JSON results
let response = await $.get(apigatewayendpoint, { q: query, l: lquery, size: 25 }, 'json');
html 正文在下方。我试过将收音机表单 ID 和输入名称相关联,但均无效
<body>
<h1>InfoLang - Movie Plot At Your Language</h1>
<form id="lang">
<p>Please select language:</p>
<input type="radio" id="it" name="fav_language" value="Italian">
<label for="it">Italian</label><br>
<input type="radio" id="fr" name="fav_language" value="French">
<label for="fr">French</label><br>
<input type="radio" id="he" name="fav_language" value="Hebrew">
<label for="he">Hebrew</label>
<br>
</form>
<hr>
<input id="search" autocomplete="off" placeholder="Search your movie" align="center">
我通过-
得到了这个
if (query.length > 2) {
let lquery
if (document.getElementById('it').checked) lquery = 'it'
if (document.getElementById('fr').checked) lquery = 'fr'
...
并用于显示
let title = results[item]._source.title
if (lquery == 'it') plot = results[item]._source.description_it
if (lquery == 'fr') plot = results[item]._source.description_fr
我正在尝试添加到 javascript 中的以下异步调用,它发送参数 q=<query>
,第二个参数 l=<lquery>
,但我没有看到它发送出去,已检查在开发工具控制台中
var searchbox = $('input#search');
var langquery = $('input#fav_language');
var timer = 0;
// Executes the search function 250 milliseconds after user stops typing
searchbox.keyup(function () {
clearTimeout(timer);
timer = setTimeout(search, 250);
});
async function search() {
// Clear results before searching
noresults.hide();
resultdiv.empty();
loadingdiv.show();
// Get the query from the user
let query = searchbox.val();
// Only run a query if the string contains at least three characters
if (query.length > 2) {
let lquery = langquery.val();
// Make the HTTP request with the query as a parameter and wait for the JSON results
let response = await $.get(apigatewayendpoint, { q: query, l: lquery, size: 25 }, 'json');
html 正文在下方。我试过将收音机表单 ID 和输入名称相关联,但均无效
<body>
<h1>InfoLang - Movie Plot At Your Language</h1>
<form id="lang">
<p>Please select language:</p>
<input type="radio" id="it" name="fav_language" value="Italian">
<label for="it">Italian</label><br>
<input type="radio" id="fr" name="fav_language" value="French">
<label for="fr">French</label><br>
<input type="radio" id="he" name="fav_language" value="Hebrew">
<label for="he">Hebrew</label>
<br>
</form>
<hr>
<input id="search" autocomplete="off" placeholder="Search your movie" align="center">
我通过-
得到了这个if (query.length > 2) {
let lquery
if (document.getElementById('it').checked) lquery = 'it'
if (document.getElementById('fr').checked) lquery = 'fr'
...
并用于显示
let title = results[item]._source.title
if (lquery == 'it') plot = results[item]._source.description_it
if (lquery == 'fr') plot = results[item]._source.description_fr