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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Jquery 正在發(fā)送多個(gè)請(qǐng)求

Jquery 正在發(fā)送多個(gè)請(qǐng)求

九州編程 2021-11-04 15:58:58
我正在嘗試制作一個(gè)搜索欄,從輸入的信件中發(fā)送提案請(qǐng)求。jQuery 發(fā)送的請(qǐng)求數(shù)與輸入的字母數(shù)相同。如果我寫“sa”,jQuery 將發(fā)送 2 個(gè)請(qǐng)求。如果我寫“Sa”,jQuery 將發(fā)送 3 個(gè)請(qǐng)求(因?yàn)槲野聪铝?shift,所以大字母被算作 2 個(gè)字母)。代碼應(yīng)該像以下說(shuō)明一樣工作: 用戶寫下他想要查找的名稱和數(shù)據(jù)庫(kù)中的代碼搜索,并顯示所有可能的搜索詞。 編輯: 腳本應(yīng)發(fā)送 2 個(gè)請(qǐng)求:第一個(gè)獲取具有“sa”的所有結(jié)果。選擇結(jié)果后。它應(yīng)該只向數(shù)據(jù)庫(kù)發(fā)送一個(gè)請(qǐng)求以獲取其余信息。我的腳本正在做什么:他正在發(fā)送他應(yīng)該做的第一個(gè)請(qǐng)求。第二個(gè)請(qǐng)求是在與字母數(shù)量相同的時(shí)間發(fā)送。即使只有一個(gè)請(qǐng)求就足夠了這是我的 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 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊

我找到了解決方案**

這是通過(guò)改變

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

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

所以只需添加

.off('點(diǎn)擊')

**


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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