Im jQuery AutoComplete का उपयोग करने की कोशिश कर रहा है, लेकिन सब मुझे मिलता है इसमें सभी परिणाम के साथ एक एकल आइटम है।
मेरे पास यह ASP.Net WebMethod है:
[WebMethod]
public static string FetchCompletionList(string term)
{
var json = JsonConvert.SerializeObject(CustomerProvider.FetchKeys(term, 8));
return json;
}
इस स्क्रिप्ट द्वारा बुलाया जा रहा है:
$("[id$="txtLKey"]").autocomplete({
minlength: 2,
source: function(request, response) {
$.ajax({
type: "POST",
url: "/Views/Crm/Json/Json.aspx/FetchCompletionList",
data: "{term: "" + $("[id$="txtLKey"]") .val() + "", count: "8"}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
response(data);
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
alert(textStatus);
alert(errorThrown.toString());
}
});
}
});
और नतीजा यह है:
जब मैं वास्तव में चाहता हूं तो विकल्पों की एक सूची है जिसे उपयोगकर्ता चुन सकता है यानी प्रत्येक NZ एक सूची में एक आइटम होना चाहिए।
उत्तर:
जवाब के लिए 0 № 1यहां पर दो समस्याएं हैं,
- आपको पास होने की जरूरत है
data.d
सेवा मेरेresponse
पसंदresponse(data.d)
. - आपका मान स्ट्रिंग अमान्य है यह होना चाहिए
{"d":["NZ0008","NZ0015","NZ0017","NZ0018","NZ0026","NZ0027","NZ003??1","NZ0035"]}