I am trying to get the ListView before filter function working. I can get the demo to work successfully on my project but when I try to query my own url, it fails. I suspect it has something to do with the data.
The example code uses: data: {
q: $input.val()
}
'q' did not work for me, so I tried the field name from my table instead "OrgName"
data: {
OrgName: $input.val()
}
That did not work either. My list comes from a single column table. I also changed the datatype to 'json' (from 'jsonp' and removed the crossdomain = true
Is there any significance to 'q' vs. 'OrgName'?
My code is:
$(document).ready(function () {
$("#autocomplete").on("listviewbeforefilter", function (e, data) {
var $ul = $(this), $input = $(data.input), value = $input.val(),
html = "";
$ul.html("");
if (value && value.length > 0) {
$ul.html("<li><div class='ui-loader'><span class='ui-icon ui-icon-loading'></span></div></li>");
$ul.listview("refresh");
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
url: "Members.asmx/test",
dataType: "json",
data: {
OrgName: $input.val()
}
})
.then(function (response) {
$.each(response, function (i, val) {
html += "<li>" + val + "</li>";
});
$ul.html(html);
$ul.listview("refresh");
$ul.trigger("updatelayout");
});
}
});
});
Any help is appreciated. Thanks.