I want to call a function from within a success function in an ajax call. But it always comes up with a js error "Object expected".
Here is the view code:
<script type="javascript">
function test(val) {
alert('val = '+val);
}
</script>
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::label('Seed Number:','seed'); ?>
<?php echo CHtml::textField('seed',$seed,array('id'=>'seed','size'=>4,'maxlength'=>4)); ?>
<p>
Square: <span id="sq"><?php echo $sq; ?></span><br />
Square root: <span id="sqrt"><?php echo $sqrt; ?></span>
</p>
<?php echo CHtml::ajaxSubmitButton('Calculate',CController::createUrl('game/test'),
array('dataType'=>'json',
'success'=>'function(data,status){ test("abc"); $("#sq").text(data.sq ); $("#sqrt").text(data.sqrt );}'));
?>
</form>
The call to test ('test("abc");') causes the problem.
How does one call a function like this?

Help















