Note that there are some explanatory texts on larger screens.

plurals
  1. POYii - Ajax Get based on drop down selection
    primarykey
    data
    text
    <p>I am trying to display the price based on the selection of product from a drop down. </p> <p>View contains: </p> <pre><code>&lt;?php $form=$this-&gt;beginWidget('bootstrap.widgets.TbActiveForm', array( 'id'=&gt;'plan-form', 'enableAjaxValidation'=&gt;true, )); ?&gt; &lt;?php echo $form-&gt;dropDownListRow($model, 'plan_id', $planList, array('id'=&gt;'planid', 'prompt'=&gt;'Select Plan', 'ajax' =&gt; array('type'=&gt;'GET', 'url'=&gt; Yii::app()-&gt;createUrl('mbr/plan/ajaxGetPrice'), 'update'=&gt;'#price'))); ?&gt; &lt;div id="price"&gt;0.00&lt;/div&gt; &lt;?php $this-&gt;endWidget(); ?&gt; </code></pre> <p>Action:</p> <pre><code>public function actionAjaxGetPrice() { Yii::log("Within AjaxGetPrice"); if (Yii::app()-&gt;request-&gt;isAjaxRequest) Yii::log("ajax request"); else Yii::log("regular request"); //$plan=Plan::model()-&gt;findByPk((int) $_GET['plan_id']); //Yii::log(serializ($plan)); // echo $plan-&gt;price; echo "10"; Yii::app()-&gt;end(); } </code></pre> <p>It is not updating the price. Its not calling the action at all. I looked at the suggestions found in Yiiframework and here and tried those and still no luck.</p> <p>when I add this to the view</p> <pre><code> &lt;?php echo CHtml::ajaxLink( "Get Price", Yii::app()-&gt;createUrl('mbr/plan/ajaxgetprice'), array( // ajaxOptions 'type' =&gt; 'GET', 'update' =&gt; '#price'), array( //htmlOptions 'href' =&gt; Yii::app()-&gt;createUrl('mbr/plan/ajaxgetprice') ) ); ?&gt; </code></pre> <p>I get the response when I click on the link, but it renders a separate page with value "10". I have URLFormat = Path. </p> <p>What am I doing wrong? Any pointers?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload