ajax link: passing parameter to data

THis is how I get the active tab from yiiTab.

Now I would like to pass the content of var datastr to my controller instead of simply 'display=mosaic" .

Anyone got an idea ?


echo CHtml::ajaxLink(

	'/images/mosaic.png', 'mosaic',array('width'=>16)),'',

	array(

		'type'=>'GET',

		'cache'=>false,

		'url'=>$this->createUrl('/ads/index',array('display'=>'mosaic')),

		'data'=>'display=mosaic',

		'beforeSend'=>'function(){

			// gets the active tab (starts at 1 )

			var curtab=$(".yiiTab ul.tabs").find("a.active");

			var href=curtab.attr("href");

			var pos=href.substring(4); //get rid of "#tab" prefix

			var datastr="display=mosaic&tab="+pos;

			// alert(datastr);

			}',

		'success'=>'function(msg){

			$("#clipall").replaceWith(msg);

			}',

		'error'=>'function(msg){alert("An error has happened");}'

		)

);

I am now passing values by POST type

and having


'data'=>array('display'=>'mosaic','tab'=>'js:$("#tabnum").val()'),

where I use an input to store the value

see this post activecheckbox-with-ajax )

However this works but a little bit late (If I press a second time I can see the value is passed). It’s like beforeSend event doesn’t recreate data when fired.

I tried


$(this).data("tab",$("#tabnum").val());

to set the data from inside beforeSend without success.

Someone has an idea how to update the data before sending the Xhtmlrequest ?