Yii Framework Forum: Display Error Message Ajax Request - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Display Error Message Ajax Request Rate Topic: -----

#1 User is offline   Dan074 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 23-June 14

Posted 04 August 2014 - 12:04 AM

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.
0

#2 User is offline   Rohit Suthar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 247
  • Joined: 12-May 14
  • Location:Mumbai, India

Posted 04 August 2014 - 01:35 AM

Your return JSON Array???
Thanks & regards,

ROHIT SUTHAR
Mumbai(India)

Follow me - @rohisuthar

yii.at

If you found your solutions.... Don't hesitate to click on '+1' button
0

#3 User is offline   Dan074 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 23-June 14

Posted 04 August 2014 - 03:27 AM

View PostRohit Suthar, on 04 August 2014 - 01:35 AM, said:

Your return JSON Array???


no, my return is text
0

#4 User is offline   Rohit Suthar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 247
  • Joined: 12-May 14
  • Location:Mumbai, India

Posted 04 August 2014 - 03:53 AM

then just write error function like this -

'error'=>'function(err){
        alert("An error has occurred. "+err);
      }',

Thanks & regards,

ROHIT SUTHAR
Mumbai(India)

Follow me - @rohisuthar

yii.at

If you found your solutions.... Don't hesitate to click on '+1' button
0

#5 User is offline   Dan074 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 23-June 14

Posted 05 August 2014 - 12:35 AM

View PostRohit Suthar, on 04 August 2014 - 03:53 AM, said:

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 );
0

#6 User is offline   Rohit Suthar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 247
  • Joined: 12-May 14
  • Location:Mumbai, India

Posted 05 August 2014 - 12:39 AM

View Postmartinus, on 05 August 2014 - 12:35 AM, said:

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



Your welcome..
Thanks & regards,

ROHIT SUTHAR
Mumbai(India)

Follow me - @rohisuthar

yii.at

If you found your solutions.... Don't hesitate to click on '+1' button
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users