2014-12-13 72 views
0

我在母版頁中有一個「SearchText」文本框。我使用的腳本代碼的搜索建議 我的代碼是:Jquery腳本不能在內容頁面上工作

<script type="text/javascript"> 
     $(document).ready(function() { 

      $('#<%=SearchText.ClientID%>').autocomplete({ 
       source: function (request, response) { 
        $.ajax({ 
         url: "SearchSuggestions.asmx/GetSuggestions", 
         data: "{ 'searchValue': '" + request.term + "' }", 
         type: "POST", 
         dataType: "json", 
         contentType: "application/json;charset=utf-8", 
         success: function (result) { 
          response(result.d); 
         }, 
         error: function (result) { 
          alert('There is a problem processing your request'); 
         } 

        }); 
       } 
      }); 
     }); 
</script> 

它工作正常上Default.aspx的。但在其他內容頁面上,這段代碼似乎並不工作。

+0

使用jQuery沒有衝突,然後嘗試 – 2014-12-13 12:55:28

+0

看在瀏覽器的JavaScript控制檯。那裏有錯誤嗎? – JJJ 2014-12-13 12:56:23

+0

請粘貼控制檯錯誤日誌 – abhati 2014-12-13 12:56:29

回答

0

使用絕對網址值。

你的Ajax請求目前要求

http://yoursite.com/{content-page-address}/SearchSuggestions.asmx/GetSuggestions 

你想

http://yoursite.com/SearchSuggestions.asmx/GetSuggestions