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),

                    array(

                        'type'=>'POST',

                        'dataType'=>'json',

                        'success'=>'function(data){

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

                                alert("success");


                             }else{

                                removeError();

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

                                    $("#viewrate-comment-input").addClass("error");

                                    $("#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) {

						$("#td'.$day.$emp_id.'").text("");

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

						$("#jobDialog'.$day.$emp_id.'").dialog("close");

                    }'),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">

EDIT

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