4

I'm having a javascript array like

var orderItems={'1':{id:'1',name:'Shirt',qty:'0'},'3':{id:'3',name:'Shoe',qty:'0'}, };

I need to pass this array to an action using a ajax button.

$this->widget('bootstrap.widgets.TbButton', array(
    'label' => 'Click me',
    'type' => 'primary',
    'htmlOptions' => array(
        'data-toggle' => 'modal',
        'data-target' => '#myModal',
        'ajax' => array(
            'type' => 'POST',
            'url' => $this->createUrl('order/AjaxUpdateOrder', 
                                      array('val' => 'profile')),
            'success' => 'function(data) { alert(data) }',
        ),
    ),
));
3
  • 1
    Please show your code in OrderController's class function actionAjaxUpdateOrder Commented Sep 10, 2012 at 6:55
  • Im just trying to access the values within it. nothing more than that Commented Sep 10, 2012 at 9:53
  • Do U got Alert (data)? It is executes? Commented Sep 10, 2012 at 10:47

1 Answer 1

3

prefix 'js:' to 'data' attribute .. like below

    'ajax' => array(
            'type' => 'POST',
            'url' => $this->createUrl('order/AjaxUpdateOrder', 
                                       array('val' => 'profile')),
            'success' => 'function(data) { alert(data) }',
            'data' => 'js:orderItems',
            'processData' => false,
    ),
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.