I'm trying to drive the select2 combo box from a very simple web method (for testing only), but nothing seems to work. I've tried with static, without static - no joy.
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
public static String getResults(String q, String page_limit)
{
return "{'id':'1','text':'test'}";
}
Here is the Jquery
$("#myHiddenField").select2({
placeholder: "Search for item",
minimumInputLength: 3,
ajax: {
url: "mypage.aspx/getResults",
dataType: 'json',
type: "POST",
params: {
contentType: 'application/json; charset=utf-8'
},
quietMillis: 100,
data: function (term, page) {
return JSON.stringify({ q: term, page_limit: 10 });
},
results: function (data) {
return { results: data };
}
}
});
I cannot for the life of me figure it out. Any thoughts or suggestions?
EDIT
I'm following the example for the 'SELECT2' plugin and more specifically the 'Infinite Scroll with Remote Data Section' see here - which works fine with the example. I'm clearly missing something obvious.