My script won't load any data in the Select2.
(我的脚本不会在Select2中加载任何数据。)
I made data from laravel controller with response JSON data, this result json (我从laravel控制器使用响应JSON数据制作了数据,此结果为json)
"results": [
{
"id": 1,
"code": "11",
"name": "jackson",
},
{
"id": 2,
"code": "12",
"name": "michael,
},
this my script code
(这是我的脚本代码)
$('.name_user').select2({
width: "100%",
placeholder: "Search...",
ajax: {
url: "{{route('name_user')}}",
processResults: function(data) {
return {
results: $.map(data, function(obj) {
return {
id: obj.id,
name: obj.name
};
})
};
},
cache: true
}
});
How do I get data from route name_user?
(如何从路由name_user获取数据?)
ask by misry translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…