0
  <?= CHtml::tag('div',array(
                        'class'=>'addcart span',
                       'id'=>'addToCart',
                        'onClick'=>CHtml::ajax(array(
                            'url'=>array('cart/AddToCart'),
                            //If we are viewing a matrix product, Add To Cart needs to pass selected options, otherwise just our model id
                            'data'=>($model->IsMaster ?
                                'js:{"'.'product_size'.'": $("#SelectSize option:selected").val(),
                                    "'.'product_color'.'": $("#SelectColor option:selected").val(),
                                    "'.'id'.'": '.$model->id.',
                                    "'.'qty'.'": $("#'.CHtml::activeId($model,'intQty').'").val() }'
                                : array('id'=>$model->id,'cart'=>'_topcart','qty'=>'js:$("#'.CHtml::activeId($model,'intQty').'").val()')),
                            'type'=>'POST',
                            'dataType'=>'json',
                            'success' => 'js:function(data){
                                if (data.action=="alert") {
                                  alert(data.errormsg);
                                } else if (data.action=="success") {
                                    animateAddToCart();
                                    '.(_xls_get_conf('AFTER_ADD_CART') ?
                                    'window.location.href="'.$this->createUrl("/cart").'"' :
                                    '$("#shoppingcart").html(data.shoppingcart);').'
                                }}'
                        )),
                    ),CHtml::link(Yii::t('product', 'Add to Cart'), '#',array('class' => 'button' , 'onclick'=>'javascript:SubmitFrm()')));
                    ?>

This is my code. AJAX is not responding.

When I refresh the page it works. Without refreshing AJAX is not responding.

What is the problem?

Abhishek Gupta
  • 109
  • 1
  • 7
  • The issue you describe is not clear to me. Are you saying that the shopping cart is updated, but you can only see the updates after a page refresh, or are you saying the cart is not updated after you press click? – crafter Jun 25 '16 at 07:35
  • yes brother........ – Abhishek Gupta Jun 27 '16 at 04:14

0 Answers0