In yii2 how to update part of a page using jquery?

Good day! I want to update part of a page, that is what the block using jquery.
$(".del-item").click(function() {
 $(".korz-block").load("main.php .korz-block");
});


This code works without мvc files and I am using yii2, can I update in yii2 in layouts in main.php part of the code in this way??? Or how to do it better, or variance
April 19th 20 at 12:08
1 answer
April 19th 20 at 12:10
Can you update the rendering result, i.e. the html, no matter what it is formed.
@maymie_Kertzmann I have doesn't work, or the way a girlfriend should specify? - Arch.Rowe commented on April 19th 20 at 12:13
@Arch.Rowe, of course the file path You specified is incorrect. - Lisette.Zieme commented on April 19th 20 at 12:16
@Lisette.Zieme,
$(".del-item").click(function() {
 $(".korz-block").load("../../views/layouts/main.php .korz-block");
});


so tried, does not work - Arch.Rowe commented on April 19th 20 at 12:19
@Arch.Rowe, no, not so.
Read in the documentation.
Specify the path you can use Url::to() or Url::toRoute
You can also try using Yii::getAsset('@web') and connect the rest of the way.
Do as I wrote in a comment. - Lisette.Zieme commented on April 19th 20 at 12:22
@Lisette.Zieme,
<?php $rel = Url::to(); ?>
the <script>
 $(".del-item").click(function() {
 $(".korz-block").load("<?= $rel ?> .korz-block");
});
</script>


I pointed out, and many variants have tried, it is useless - Arch.Rowe commented on April 19th 20 at 12:25
@Arch.Rowe, read carefully my comment under Your question.
$rel = Url::to()
Read the documentation on how to use Url::to(); - Lisette.Zieme commented on April 19th 20 at 12:28
@Arch.Rowe, https://www.yiiframework.com/doc/guide/2.0/ru/runt... - Lisette.Zieme commented on April 19th 20 at 12:31

Find more questions by tags JavaScript