Skip to content

Commit

Permalink
Catch when ajax error - Fixed johnitvn/yii2-ajaxcrud#1
Browse files Browse the repository at this point in the history
  • Loading branch information
johnitvn committed Jul 3, 2015
1 parent 1d96901 commit 3468630
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion assets/ajaxcrud.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
return this.attr(name) !== undefined;
};


String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}


function closeModal(){
Expand Down Expand Up @@ -66,6 +68,11 @@
$.ajax({
url:settings.url,
method:settings.method,
error:function(request, textStatus, errorThrown){
$(modalId).find('.modal-header .modal-title').remove();
$(modalId).find('.modal-header').append('<div class="modal-title"><h4 class="modal-title">'+textStatus.capitalizeFirstLetter()+' - '+errorThrown+'</h4></div>');
$(modalId).find('.modal-body').html(request.responseText);
},
success:function(response){
$(modalId).find('.modal-header .modal-title').remove();
$(modalId).find('.modal-header').append('<div class="modal-title"><h4 class="modal-title">'+settings.title+'</h4></div>');
Expand Down
2 changes: 1 addition & 1 deletion assets/ajaxcrud.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3468630

Please sign in to comment.