Access to XMLHttpRequest at 'url::to(['site/wikiprod2'])' from origin 'http://**.**.**.**' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
jquery.js:10109
POST url::to(['site/wikiprod2']) net::ERR_FAILED
send @ jquery.js:10109
ajax @ jquery.js:9690
(anonymous) @ index.php?r=site%2Fwiki:170
dispatch @ jquery.js:5430
elemData.handle @ jquery.js:5234
Код: Выделить всё
<?php $this->beginContent('@app/views/layouts/main.php'); ?>
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3">
<?= kartik\tree\TreeViewInput::widget([
// single query fetch to render the tree
// use the Product model you have in the previous step
'query' => frontend\models\Tree::find()->addOrderBy('root, lft'),
'headingOptions'=>['label'=>'Выбрать пункт меню'],
'name' => 'kv-product', // input name
'value' => '1', // values selected (comma separated for multiple select)
'asDropdown' => false, // will render the tree input widget as a dropdown.
'multiple' => false, // set to false if you do not need multiple selection
//'fontAwesome' => true, // render font awesome icons
'rootOptions' => [
'label'=>'<i class="fa fa-tree"></i>', // custom root label
'class'=>'text-success'
],
'options'=>['disabled' => false],
'displayValue' => 0,
'isAdmin' => true,
'showIDAttribute' => true,
'emptyNodeMsg' => ' type some msg here ... .',
'showCheckbox' => true,
'options' => ['id' => 'treeID'],
'allowNewRoots' => false,
'toolbar' => [
'create' => ['alwaysDisabled' => true],
//'remove' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-up' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-down' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-left' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-right' => ['alwaysDisabled' => !(AdminController::isAdmin())],
//'remove' => false,
],
'nodeView' => '@kvtree/views/_form',
'nodeAddlViews' => [
1 => '',
2 => '',
3 => '',
4 => '',
5 => '@app/views/krajeeproducttree/product'],
'cascadeSelectChildren' => false,
//'nodeAddlViews' => [,
//],
]);?>
</div>
<div class="col-lg-9 col-md-9 col-sm-8">
<?= $content ?>
</div>
</div>
</div>
<?php $this->endContent(); ?>
<script>
$('#treeID').on('treeview:selectcomplete', function(event, jqXHR)
{
console.log('treeview:selectcomplete')
});
</script>
<script>jQuery(function ($) {
$('#treeID').on('treeview:selected', function(event, key, data, textStatus, jqXHR)
{
console.log('12345')
})
//jQuery('#w1').treeview(treeview_93576f87)
});
</script>
<script>jQuery(function ($) {
jQuery('.kv-selected').click(function()
{
var getNum = document.getElementById('treeID').value;
console.log(getNum + 'выбор меню')
$.ajax(
{
url : "Url::to(['site/wikiprod2'])",
type: 'POST',
data : {"number": getNum},
success : function(res){
console.log(res);
},
}
);
});
});
</script>