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
94b043ecf5
commit
d6656dffc0
@ -98,15 +98,9 @@ jQuery.fn.dialogForm = function (options) {
|
||||
$('#' + containerId + ' input').each(function (index, elem) {
|
||||
formData[elem.name] = elem.value;
|
||||
});
|
||||
$(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",
|
||||
success:function (data, textStatus, jqXHR) {
|
||||
|
||||
// Success actions ...
|
||||
var onSuccess = function (jqXHR, textStatus,data) {
|
||||
if (options.redirect) {
|
||||
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
||||
var redirectUrl = options.redirect;
|
||||
@ -120,9 +114,10 @@ jQuery.fn.dialogForm = function (options) {
|
||||
options.postUpdate(formData);
|
||||
}
|
||||
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);
|
||||
// Mark fields with errors ...
|
||||
var fieldErrors = errors.fieldErrors;
|
||||
@ -136,17 +131,36 @@ jQuery.fn.dialogForm = function (options) {
|
||||
inputField.parent().addClass('error');
|
||||
}
|
||||
}
|
||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||
acceptBtn.button('reset');
|
||||
};
|
||||
|
||||
} else {
|
||||
var onError = function (jqXHR, textStatus, errorThrown) {
|
||||
console.log(errorThrown);
|
||||
console.log(jqXHR);
|
||||
dialogElem.modal('hide');
|
||||
$('#messagesPanel div div').text(errorThrown);
|
||||
$('#messagesPanel').show()
|
||||
}
|
||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user