Select2 遥控器的正确 JSON 格式是什么
What is the right JSON format for Select2 remote
我对 JSON 格式有点迷茫,我必须 return Select2 才能正常工作。
我的 returned JSON 用 fiddler 捕获:
我的 Select2 设置(#FuncionarioID 是 select 输入):
$('#FuncionarioID').select2({
ajax: {
dataType: "json",
url: "Ajax.ashx?Action=FuncionarioSelect2",
results: function (data) {
return { results: data };
},
cache:false
}
});
我一直在 Whosebug 中阅读有关同一主题的问题,我尝试了答案,其中 none 对我有用。您对解决这个问题有什么建议吗?我已经尝试过 return 这样的对象 {"id":"1060","text":"teste 1"} 但它也没有用。
在此先感谢您的帮助。
尝试像这样更新您的函数:
$('#FuncionarioID').select2({
ajax: {
dataType: "json",
url: "Ajax.ashx?Action=FuncionarioSelect2",
cache: false,
processResults: function (data, page) {
return {
results: data
};
}
}
});
我对 JSON 格式有点迷茫,我必须 return Select2 才能正常工作。
我的 returned JSON 用 fiddler 捕获:
我的 Select2 设置(#FuncionarioID 是 select 输入):
$('#FuncionarioID').select2({
ajax: {
dataType: "json",
url: "Ajax.ashx?Action=FuncionarioSelect2",
results: function (data) {
return { results: data };
},
cache:false
}
});
我一直在 Whosebug 中阅读有关同一主题的问题,我尝试了答案,其中 none 对我有用。您对解决这个问题有什么建议吗?我已经尝试过 return 这样的对象 {"id":"1060","text":"teste 1"} 但它也没有用。
在此先感谢您的帮助。
尝试像这样更新您的函数:
$('#FuncionarioID').select2({
ajax: {
dataType: "json",
url: "Ajax.ashx?Action=FuncionarioSelect2",
cache: false,
processResults: function (data, page) {
return {
results: data
};
}
}
});