Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Json Not Working In Ajaxsubmit Button

$
0
0
i have the following code in controller

public function actionTest($id)
{
$test=array(1,2,3);
print_r($test);

}


in index.php


<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'job-form',
'enableAjaxValidation' => true,
));

echo CHtml::ajaxSubmitButton('Save', $this->createUrl('site/test', array('id' => 12)), array(
'type' => 'POST',
'dataType' => 'json',
'success' => 'function(data){
alert(data);
}',
));

$this->endWidget();
?>





but i can't get the alert to work and the array is not getting displayed..
if i comment the datatype it works fine...

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>