Hazel Mahmud

Hazel Mahmud

  • NA
  • 299
  • 65.9k

json autocomplete doesn't accept certain letter

Mar 22 2015 12:11 AM
hello..
 
 
i have a webservice that retrieve username. i manage to call it to a autocomplete textbox using json but it doesn't accept certain letter, e.g : a,d,n,i. why is that?.. how to fix it?.. below are my codes :
 
webservice.asmx 
 
[WebMethod]
public List<string> GetStaffName(string name)
{

using (AseConnection persisConn = ClassConn.GetPersisConnection())
{
AseDataAdapter da = new AseDataAdapter();

persisConn.Open();

da.SelectCommand = new AseCommand("select name = ltrim(f786desc+' '+ f630nama) from t630staf, t786gelaran where f786kdgelar =* f630kdgelar and f630status != '9' AND f630nama like (LOWER('%@SearchName%')) union SELECT name = f620nama FROM t620sambilan where f620kdstatus <> '9' AND f620nama like (LOWER('%@SearchName%')) order by name", persisConn);
DataTable dt = new DataTable();
da.Fill(dt);

List<string> staffs = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
staffs.Add(dt.Rows[i]["name"].ToString());
}

return staffs;
}
 
aspx code : 
 
 
<script type="text/javascript" >
$(function () {
$('#<%= txtName.ClientID %>').autocomplete({
source: function (request, respponse) {
$.ajax({
url: "AutoComplete.asmx/GetStaffName",
data: "{'name' : '" + request.term + "'}",
type: "POST",
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (result) {
respponse(result.d);
},
error: function (result) {
alert('There is a problem processing your request');
}
});
}
});
}); 

Answers (3)