0
我有兩個jQuery的用於獲取母版頁上,從數據庫中的數據:多個實例
<script type="text/javascript">
$(document).ready(function() {
SearchText1();
});
function SearchText1() {
$("#txtSearch2").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "ItemGetter.aspx/GetAutoCompleteData",
data: "{'username':'" + document.getElementById('txtSearch2').value + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Error");
}
});
}
});
}
</script>
,另一種!
<script type="text/javascript">
$(document).ready(function() {
SearchText1();
});
function SearchText1() {
$(".manish").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "ItemGetter.aspx/GetAutoCompleteData",
data: "{'username':'" + document.getElementById('txtSearch1').value + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Error");
}
});
}
});
}
</script>
和我想實現自動完成的兩個文本框分別是:
<asp:TextBox id="txtSearch2" placeholder="Search Item" class="bjg autosuggest" runat="server" style="margin-top:8px"></asp:TextBox>
<asp:TextBox id="txtSearch1" placeholder="Search Item" class="manish" runat="server" style="margin-top:8px"></asp:TextBox>
我已經注意到,我寫劇本爲準第不起作用。我也嘗試過不同的類作爲選擇器,我也嘗試使用id的文本框。但這是我無法理解的。即使我試圖將一個文本框放在母版頁中,另一個放在內容頁中。但似乎沒有爲我工作。請看一下。