Last Updated: February 25, 2016
·
214
· samjamzee

Commmon Success Js

success: function(data) {
// message.html('Complete...!');
setTimeout(function() {
message.addClass('hidden');
}, 1000);
if (data.success) {
var url = data.url;
if (url.charAt(0) == '#') {
$('div[id^="modal-"]').modal('hide');
$(url).modal('show');
} else {
window.location = data.url;
}
} else {
msg(data.message);
$(".text-danger").remove();
$(".has-error").removeClass('has-error');
$.each(data.message, function(index, data) {
$(":input[name='" + index + "']").parent().removeClass('has-error');
if ((data[0] != '')) {

                $(":input[name='" + index + "']").parent().append("<div class='text-danger'>" + data[0] + "</div>");
                $(":input[name='" + index + "']").parent().addClass('has-error');
            }
        })
    }
}