第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Jquery 正在發(fā)送多個請求

Jquery 正在發(fā)送多個請求

九州編程 2021-11-04 15:58:58
我正在嘗試制作一個搜索欄,從輸入的信件中發(fā)送提案請求。jQuery 發(fā)送的請求數(shù)與輸入的字母數(shù)相同。如果我寫“sa”,jQuery 將發(fā)送 2 個請求。如果我寫“Sa”,jQuery 將發(fā)送 3 個請求(因為我按下了 shift,所以大字母被算作 2 個字母)。代碼應(yīng)該像以下說明一樣工作: 用戶寫下他想要查找的名稱和數(shù)據(jù)庫中的代碼搜索,并顯示所有可能的搜索詞。 編輯: 腳本應(yīng)發(fā)送 2 個請求:第一個獲取具有“sa”的所有結(jié)果。選擇結(jié)果后。它應(yīng)該只向數(shù)據(jù)庫發(fā)送一個請求以獲取其余信息。我的腳本正在做什么:他正在發(fā)送他應(yīng)該做的第一個請求。第二個請求是在與字母數(shù)量相同的時間發(fā)送。即使只有一個請求就足夠了這是我的 jQuery 代碼:$('.sucherInput').on('keyup', function () {// ** .sucherInput is the class of the input fieldvar inputValue = $('.sucherInput').val();var result      = $(".sucherres");var resultList  = $(".sucherres ul");if (inputValue.length) {  console.log(inputValue);  $.post("action/php/artikelSucher.php", {                       name: inputValue  }).done(function(data){                         // Display the returned data in browser    //console.log(data);     resultList.html(data);    result.show();  }); //.done} else{  console.log("empty");  resultList.empty();  result.hide();}$(document).on("click", ".sucherres ul li p", function(){  //set the search bar value as same as the clicked <p> tag  $('.sucherInput').val($(this).text());  //clear the Proposals list  $(resultList).empty();  $(result).hide();  //renew the value of the search bar   //since im taking the value which have to be searched in the database from the searchbar  var sucherLastIndex = $('.sucherInput').val();  console.log("Getting data from database: " + sucherLastIndex);  //load the data into the HTML file  $("#updateDiv #info").load("action/php/index-preis-liste.php", {    name: sucherLastIndex  });});});這是 Html 代碼:<div class="sucher">     <ul style="width: 100%; margin-bottom: 0;">         <li style="width: 33%;">             <input type="text" class="sucherInput" placeholder="Geben Sie einen Suchbegriff ein">         </li>     </ul>     <div class="sucherres">         <ul>            <!-- ## HERE COMES THE Proposals ## -->                   </ul>  </div>  <div id="info">  </div>
查看完整描述

1 回答

?
繁星點點滴滴

TA貢獻1803條經(jīng)驗 獲得超3個贊

我找到了解決方案**

這是通過改變

$(document).on("click", ".sucherres ul li p", function(){

$(document).off('click').on("click", ".sucherres ul li p", function(){

所以只需添加

.off('點擊')

**


查看完整回答
反對 回復 2021-11-04
  • 1 回答
  • 0 關(guān)注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號