我是" SearchText"母版页中的文本框。我使用脚本代码进行搜索建议 我的代码是:
<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 :(得分:0)
使用绝对网址值。
您的ajax请求目前要求
http://yoursite.com/{content-page-address}/SearchSuggestions.asmx/GetSuggestions
你想要
http://yoursite.com/SearchSuggestions.asmx/GetSuggestions