2016-04-13 66 views
0

Ben jQuery ile bir çok deneyim vardı ama aşağıda başarıyla arama sonucu açılan sıralar halinde arama karakterlerini kalınlaştırmak olan Otomatik Tamamlama kodu değil:jQuery Otomatik tamamlama sözdizimi?

.autocomplete({ 
     delay: 500, 
     minLength: 0, 

     source: function(request, response) { 
     // delegate back to autocomplete, but extract the last term 
     var list = $.ui.autocomplete.filter(availableTags, extractLast(request.term)); 
     if (request.term) { 
      regex = new RegExp('(' + extractLast(request.term) + ')', 'gi'); 
      list = list.map(function(item) { 
      return { 
       label: item.label.replace(regex, '<b>$1</b>'), 
       value: item.value 
      } 
      }) 
     } 
     response(list); 
     }, 

ben artık hiç kaynağını geçmek için çalışıyorum AJAX araması. İlk kod örneği gibi cesur metin karakterleri almak için düzenlemenin aşağıdaki AJAX koduna ne olacağını bilen biri var mı?

.autocomplete({ 
     delay: 500, 
     minLength: 0, 

     source: function (request, response) { 
       $.ajax({ 
        url: 'default.aspx/fGetCityLookupData', 
        data: "{'strSearchText': '" + extractLast(request.term) + "'}", 
        dataType: "json", 
        type: "POST", 
        contentType: "application/json; charset=utf-8", 
        success: function (data) { 
         response($.map(data.d, function (item) { 
          return { 
           label: item.split('|')[1], 
           value: item.split('|')[0] 
          } 
         })) 
        }, 
        error: function (response) { 
         alert(response.responseText); 
        }, 
        failure: function (response) { 
         alert(response.responseText); 
        } 
       }); 
      }, 

TIA Mark

cevap

İlgili konular