Display Error Message Ajax Request

hello, I have problem to display error message from ajax request, here is my code :




<?php echo CHtml::ajaxButton ("Proses", CController::createUrl('tool/prosesTutupBukuCabang'),

                  array('type'=>"POST",

						 'update' => '#data_tutupBukuCabang',

                         'data'=> array('periodeBulan' => 'js:document.getElementById("periodeBulanCabang").value',

										'periodeTahun' => 'js:document.getElementById("periodeTahunCabang").value',),

						'success'=>'function(data){

							$("#data_tutupBukuCabang").empty();

							$("#data_tutupBukuCabang").append(data);

							$("#data_tutupBukuCabang").hide();

							$("#data_tutupBukuCabang").css({"background-color":"yellow","height":"20px","text-align":"center","line-height":"20px","color":"green"}); 

							$("#data_tutupBukuCabang").show( "slow" ).delay(3000);

							$("#data_tutupBukuCabang").hide(1000);

						}',

						'error'=>'function(data,status){

							alert(status.responseText);

						}',

									));?>



after ajaxButton click, it’s process results error but I don’t know how to show the error messages.

Your return JSON Array???

no, my return is text

then just write error function like this -


'error'=>'function(err){

        alert("An error has occurred. "+err);

      }',

thank you, but err return object. but, it works after I append .responseText so alert("An error has occurred. "+err.responseText );

Your welcome…