You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Guys
in bforms Ajax i encountered following scenario:
when handling serverError and error, i get my Error Messages twice:
var ajaxOptions = {
name: '|setGroups|',
url: this.options.index.setGroupsUrl,
type: 'post',
context: this,
data: { value: e.currentTarget.dataset.value },
context: this,
success: function (response, args) {
var r = response;
if (r.Status == 1) //Success
{
if (r.Data == undefined || r.Data.Status == undefined) {
PersonalPresenceIndex.prototype._addSuccess(r.Message);
PersonalPresenceIndex.prototype._alertTimeout(5000);
}
else //We have Data filled. It seems that there is an exception happening
{
if (r.Data.Status == 4) {
PersonalPresenceIndex.prototype._addAlert(r.Data.Message);
PersonalPresenceIndex.prototype._alertTimeout(10000);
}
}
}
else {
if (r.Status == 4) //Server Error
{
PersonalPresenceIndex.prototype._addAlert(r.Message);
PersonalPresenceIndex.prototype._alertTimeout(10000);
}
}
},
validationError: function(response)
{
var r = response;
PersonalPresenceIndex.prototype._addAlert(r.Message);
PersonalPresenceIndex.prototype._alertTimeout(10000);
},
serverError: function(response)
{
var r = response;
PersonalPresenceIndex.prototype._addAlert(r.Message);
PersonalPresenceIndex.prototype._alertTimeout(10000);
},
denied: function(response)
{
var r = response;
PersonalPresenceIndex.prototype._addAlert(r.Message);
PersonalPresenceIndex.prototype._alertTimeout(10000);
},
error: function (response) {
var r = response;
PersonalPresenceIndex.prototype._addAlert(r.Message);
PersonalPresenceIndex.prototype._alertTimeout(10000);
},
loadingElement: $('.groupToggle'),
loadingClass: 'loading'
};
$.bforms.ajax(ajaxOptions);
Im my opinion it should be an else if handling here, as if I have already handled one specific type of handler, i dont want to handle it also for the more general error:
deferredXHR.done($.proxy(function (status, args) {
if (status === this._statusEnum.Success) {
if (typeof opts.success === "function") {
opts.success.apply(opts.context, args);
}
} else if (status === this._statusEnum.ValidationError) {
if (typeof opts.validationError === "function") {
opts.validationError.apply(opts.context, args);
}
else if (typeof opts.error === "function") {
opts.error.apply(opts.context, args);
}
}
if (status === this._statusEnum.ServerError) {
if (typeof opts.serverError === "function") {
opts.serverError.apply(opts.context, args);
}
else if (typeof opts.error === "function") {
opts.error.apply(opts.context, args);
}
}
if (status === this._statusEnum.Denied) {
this._handleUnauthorized.apply(self, [xhrSettings]);
if (typeof opts.denied === "function") {
opts.denied.apply(opts.context, args);
}
else if (typeof opts.error === "function") {
opts.error.apply(opts.context, args);
}
}
}, this));
deferredXHR.fail($.proxy(function (status, args) {
if (status === this._statusEnum.ServerError) {
if (typeof opts.serverError === "function") {
opts.serverError.apply(opts.context, args);
}
} else if (status === this._statusEnum.Denied) {
this._handleUnauthorized.apply(self, [xhrSettings]);
if (typeof opts.denied === "function") {
opts.denied.apply(opts.context, args);
}
}
else if (status === this._statusEnum.Timeout) {
if (typeof opts.onTimeout === "function") {
opts.onTimeout.apply(opts.context, args);
}
}
else if (status === this._statusEnum.Offline) {
if (typeof opts.offline === "function") {
opts.offline.apply(opts.context, args);
}
}
else if (typeof opts.error === "function") {
opts.error.apply(opts.context, args);
}
}, this));
Regards Dumitru
The text was updated successfully, but these errors were encountered:
Hi Guys
in bforms Ajax i encountered following scenario:
when handling serverError and error, i get my Error Messages twice:
Im my opinion it should be an else if handling here, as if I have already handled one specific type of handler, i dont want to handle it also for the more general error:
Regards Dumitru
The text was updated successfully, but these errors were encountered: