cksrc
cksrc

Reputation: 2347

Update Yii grid view on ajax call

Trying to update the contents of my grid view after an ajax call to an action that triggers some DB changes:

$.ajax({ 'url': '" . $this->createUrl('//myController/myAction') . "', 'type': 'post', 'data': serial, 'success': $.fn.yiiGridView.update('my-grid'), } });

My problem is that the grid update ajax call seems to be called before my ajax call is completed so although the grid values are updated in the db the changes can only be seen after I manually refresh the page.

Upvotes: 1

Views: 5538

Answers (1)

Michael Härtl
Michael Härtl

Reputation: 8587

You need to wrap that call in a function:

'success': function(){ $.fn.yiiGridView.update('my-grid'); }

Upvotes: 4

Related Questions