在下面的代码中,我必须使用唯一的URL来获取必要的数据表单服务器以使用alpaca library,我如何组合这些URL来从服务器获取带有一个URL的数据,例如:
http://127.0.0.1:8000/content_categories
我的alpaca
库实现是:
$("#content_categories").alpaca({
"data": [],
"schema": "http://127.0.0.1:8000/schema",
"options": "http://127.0.0.1:8000/options",
"postRender": function (control) {
$("#multiselect").parent().find("input[type=checkbox]").uniform();
}
});
和发送结果的服务器实现:
Route::get('/schema', function () {
echo json_encode(
["type" => 'array',
"items" =>
["type" => "string",
"enum" => ["salam", "ma"],
"minItems" => 1,
"maxItems" => 20
]
]);
});
Route::get('/options', function () {
echo json_encode(
["helper" => "یک یا چند مورد انتخاب کنید",
"type" => "select",
"id" => "multiselect",
"focus" => false,
"size" => 1]
);
});
例如:
Route::get('/content_categories', function () {
echo json_encode([
"schema" => ["type" => 'array',
"items" =>
["type" => "string",
"enum" => ["salam", "ma"],
"minItems" => 1,
"maxItems" => 20
]
],
"options" => ["helper" => "یک یا چند مورد انتخاب کنید",
"type" => "select",
"id" => "multiselect",
"focus" => false,
"size" => 1
]
]
);
});
答案 0 :(得分:1)
是的,你可以只使用一个web服务,你应该在使用ajax进行alpaca初始化之前调用它...并且你还应该将响应分配给这样的模式和选项对象:
"schema": response.schema,
"options": response.options
这是一个fiddle。