ورود

View Full Version : سوال: مشکل در اجذای auto complete



sabagood
دوشنبه 02 آبان 1390, 14:02 عصر
سلام من نمیدونم چرا کدم اجرا نمیشه؟
این برای .js:(البته 'asdf' آلرت میشه ها)






$.ajax({
type:"POST",
url: "../Common.asmx/GetFileName",
data:"{}",
async:true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success:function(result)
{

if(result.hasOwnProperty("d"))
result=result.d;
alert('asdf');
alert(result[5].Name.toString());
$("#txtFileName").autocomplete({

minLength: 0,
source: result,
focus: function(event, ui) {
$('#txtFileName').val(ui.item.Name);
mm=ui.item.FileId;

// return false;

},
select: function(event, ui) {
$('#txtFileName').val(ui.item.Name);
mm=ui.item.FileId;
alert(mm);

return false;
}});

},
error:function(){alert("nashod");}


})


ایتم وب متدم


[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<FileTitle> GetFileName()
{
List<FileTitle> f = new List<FileTitle>();
db = new TeleWorkingDBDataContext();
Table<File> ff = db.GetTable<File>();
var sf = from x in ff
select new
{
x.FileId,
x.FileTitle
};
var sh = sf.ToList();
for (int i = 0; i < sh.Count; i++)
{
FileTitle ft = new FileTitle();
ft.FileId = sh[i].FileId;
ft.value = sh[i].FileTitle;
ft.Name = sh[i].FileTitle;
f.Add(ft);

//
}
return f;
}