Jquery Doesnt Work With Ajaxsubmitbutton

Just added an ajaxSubmitButton to my view and I cant call a javascript function which I can call with a normal submitButton.

Here is the code for the button

CHtml::ajaxSubmitButton(Yii::t('dictionary', '_add_track'), Yii::app()->createUrl('track/new/'.$project_id),





                             if(data.status =="success"){




                                $.each(data, function(key, val) {


                                    $("#newtrack-form #"+key+"_em_").text(val);

                                    $("#newtrack-form #"+key+"_em_").show();





and I am getting the error that my javascript function is not a function.

It still makes no sense why it works with a normal submitButton.

Hope someone can help me out here.

<?php echo CHtml::ajaxSubmitButton(Yii::t('job','Save'),

						CHtml::normalizeUrl(array('Attendances/Addnew','render'=>false)),array('success'=>'js: function(data) {


						$("#jobDialog123'.$day.$emp_id.'").html("<span class=\"abs\"></span>","");


                    }'),array('id'=>'closeJobDialog'.$day.$emp_id,'name'=>'save')); ?>

Here important thing… u have to note js: (its very important. i hope it will help you)

Thanks for the tip, but it didnt solve the problem…

But I guess the output isnt correct aswell.

It looks like:

<input id="yt0" type="submit" value="Add track" name="yt0">


Alright, it seems like i have to registerScriptFile in my controller action, but I still dont get it why it works with normal submitButton?