0
我有下面的代碼jQuery的自動完成文本框jquery autocomplete ---如果json是空的?
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "AutoCompleteFetchService.asmx/getUserNames",
data: "{'TextBoxVal':'" + document.getElementById('txtName1').value + "'}",
dataType: "json",
success: function (data1) {
response(data1.d);
},
我得到的建議正確。如果沒有數據返回,我試圖顯示" No search found"
。如果JSON是空時遇到以下循環執行
if(typeof (data1.d) == 'undefined')
{
}
,但我怎樣才能返回或更改顯示的建議「沒有找到數據」?
有沒有更簡單的方法?