I want to capture javascript/PHP variable in the ajaxoptions' options. e.g;
CHtml::ajaxLink("My link", Yii::app()->createUrl('controller/definition'), array(
'data' => array("id" => $model->id),
'type' => 'POST',
'error' => 'js:function(data){}',
'beforeSend' => 'js:function(request){}',
'success' => 'js:function(data){
alert(jQuery(this).attr("id"));
alert({$model->id});
}',
'complete' => 'js:function(data){}',
//'update'=>'#where_to_put_the_response',
), array(
"confirm" => "Are you sure you want to delete?",
"id" => "linkID",
"href" => "javascript:;",
"title" => "mTitle"
)
);
In the success option I have two alerts to show you guyz how do i want it. Which doesn't display correct data. Is there any way to get the php variables and the jQuery(this) object?
I have extracted the data i wanted from "jQuery(this)". Actually "jQuery(this)" returned me the data in a different format. Below is the code.
CHtml::ajaxLink("My link", Yii::app()->createUrl('controller/definition'), array(
'data' => array("id" => $model->id),
'type' => 'POST',
'error' => 'js:function(data){}',
'beforeSend' => 'js:function(request){
mdata=(jQuery(this)[0]["data"]).replace( /^\D+/g, "");
}',
'success' => 'js:function(data){
alert(mdata);
}',
'complete' => 'js:function(data){alert(mdata);}',
//'update'=>'#where_to_put_the_response',
), array(
"confirm" => "Are you sure you want to delete?",
"id" => "linkID",
"href" => "javascript:;",
"title" => "mTitle"
)
);
if alert the "jQuery(this)" like alert(JSON.stringify(jQuery(this)));
- you will get the idea of the data returned.