mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Fix jQuery resturn status.
This commit is contained in:
parent
3b23fead8e
commit
6d1a00291e
@ -98,15 +98,9 @@ jQuery.fn.dialogForm = function (options) {
|
|||||||
$('#' + containerId + ' input').each(function (index, elem) {
|
$('#' + containerId + ' input').each(function (index, elem) {
|
||||||
formData[elem.name] = elem.value;
|
formData[elem.name] = elem.value;
|
||||||
});
|
});
|
||||||
$(acceptBtn).button('loading');
|
|
||||||
var dialogElem = this;
|
// Success actions ...
|
||||||
jQuery.ajax(url, {
|
var onSuccess = function (jqXHR, textStatus,data) {
|
||||||
async:false,
|
|
||||||
dataType:'json',
|
|
||||||
data:JSON.stringify(formData),
|
|
||||||
type:options.type ? options.type : 'POST',
|
|
||||||
contentType:"application/json; charset=utf-8",
|
|
||||||
success:function (data, textStatus, jqXHR) {
|
|
||||||
if (options.redirect) {
|
if (options.redirect) {
|
||||||
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
||||||
var redirectUrl = options.redirect;
|
var redirectUrl = options.redirect;
|
||||||
@ -120,9 +114,10 @@ jQuery.fn.dialogForm = function (options) {
|
|||||||
options.postUpdate(formData);
|
options.postUpdate(formData);
|
||||||
}
|
}
|
||||||
dialogElem.modal('hide');
|
dialogElem.modal('hide');
|
||||||
},
|
};
|
||||||
error:function (jqXHR, textStatus, errorThrown) {
|
|
||||||
if (jqXHR.status == 400) {
|
// On error message
|
||||||
|
var onFailure = function(jqXHR,textStatus, data){
|
||||||
var errors = JSON.parse(jqXHR.responseText);
|
var errors = JSON.parse(jqXHR.responseText);
|
||||||
// Mark fields with errors ...
|
// Mark fields with errors ...
|
||||||
var fieldErrors = errors.fieldErrors;
|
var fieldErrors = errors.fieldErrors;
|
||||||
@ -136,17 +131,36 @@ jQuery.fn.dialogForm = function (options) {
|
|||||||
inputField.parent().addClass('error');
|
inputField.parent().addClass('error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||||
|
acceptBtn.button('reset');
|
||||||
|
};
|
||||||
|
|
||||||
} else {
|
var onError = function (jqXHR, textStatus, errorThrown) {
|
||||||
console.log(errorThrown);
|
console.log(errorThrown);
|
||||||
console.log(jqXHR);
|
console.log(jqXHR);
|
||||||
dialogElem.modal('hide');
|
dialogElem.modal('hide');
|
||||||
$('#messagesPanel div div').text(errorThrown);
|
$('#messagesPanel div div').text(errorThrown);
|
||||||
$('#messagesPanel').show()
|
$('#messagesPanel').show()
|
||||||
}
|
|
||||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||||
acceptBtn.button('reset');
|
acceptBtn.button('reset');
|
||||||
|
};
|
||||||
|
|
||||||
|
$(acceptBtn).button('loading');
|
||||||
|
var dialogElem = this;
|
||||||
|
jQuery.ajax(url, {
|
||||||
|
async:false,
|
||||||
|
dataType:'json',
|
||||||
|
data:JSON.stringify(formData),
|
||||||
|
type:options.type ? options.type : 'POST',
|
||||||
|
contentType:"application/json; charset=utf-8",
|
||||||
|
statusCode:{
|
||||||
|
200: onSuccess,
|
||||||
|
201: onSuccess,
|
||||||
|
204: onSuccess,
|
||||||
|
400: onFailure,
|
||||||
|
444: onError,
|
||||||
|
500: onError,
|
||||||
|
501: onError
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
Loading…
Reference in New Issue
Block a user