Answer the question
In order to leave comments, you need to log in
Getting the result of the php script, after loading the page in yii?
Hello, there is a script that accesses the API, takes certain data from there and displays it in the view. Now all this is done in the component and thus I pass it on the view:
<? foreach (Yii::app()->spsr->getCalcDelivery() as $cityName => $city) : ?>
<div class="product-body">
<div class="num num-box">
<input type="text" name="" value="1" class="js-inc-count"/>
<a href="" class="plus js-inc-plus"></a>
<a href="" class="minus js-inc-minus"></a>
</div>
<div class="price">
<span><?= $item->getEndPrice() ?> руб.</span>
</div>
<div class="time">
<span><span class="test"><?= $city['time']; ?></span> дн.</span>
</div>
<div class="cart">
<button data-stock-id="<?= $city['stock_id'] ?>" href="" class="button js-to-cart">В корзину</button>
</div>
<? /*
<div class="favorite">
<a href="" data-id="<?= $item->id; ?>" class="<?= $item->isFavorite() ? 'act' : ''; ?>">В
избранное</a>
</div>
*/ ?>
</div>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
Wait for the page to finish loading, throw an ajax request into a pre-prepared action, process the request there and give out some data. Or renders and renders some html, for example:
public function actionGetMyBlock(){
return $this->renderAjax('someView',[
'data'=>Yii::app()->spsr->getCalcDelivery()
]);
}
$( document ).ready(function() {
$('.someContainer').load('/mycontroller/get-my-block');
});
<?php foreach ($data as $cityName => $city) : ?>
.............
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question