Good morning everyone,
I have a very strange problem with a system I picked up for maintenance. All the requests I make to the server have been building up.
For example:
- I perform user exclusion 01. It sends the request and deletes the user without problems.
- I delete the user 02. It sends the request to delete the user 01 and 02, the first one of the error (because the user does not exist anymore) and excludes user 02 without problems.
Has anyone ever had a similar problem, is it some configuration ??
I'm not very experienced in jquery, any tips already help me a lot.
Follow the code that makes the call
function confirmar(acao, elemento, campo_nome, campo_valor) {
$('.crud_msg').text(acao + " " + elemento + " com " + campo_nome + " igual " + campo_valor);
$('#confirm_modal').modal('show');
$('#confirm_modal').on('shown.bs.modal', function() {
$('#confirm_modal_nbtn').focus();
}).on('click', '#confirm_modal_ybtn', function(e) {
$('#confirm_modal').modal('hide');
$.ajax({
url : '/apsig2/crud?action=' + acao + '&elemento=' + elemento + '&campo_nome=' + campo_nome + '&campo_valor=' + campo_valor,
type : "POST",
success : function(data, textStatus, jqXHR) {
obj = $.parseJSON(data);
if (obj.success) {
$('#user-table').bootstrapTable('refresh');
$('#action_success').modal('show');
} else {
$('#action_failure').modal('show');
}
verifySession();
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
$('#action_failure').modal('show');
}
});
});
}
Here is the code that generates the answer:
private void process(HttpServletRequest request, HttpServletResponse response) throws IOException {
this.req = request;
getElementAndAction();
jsonResult = new JSONObject();
JSONArray jsonResultArray = new JSONArray();
String resultado = "";
try {
campoNome = requestGetParameter("campo_nome", req) != null ? requestGetParameter("campo_nome", req) : "";
campoValor = requestGetParameter("campo_valor", req) != null ? requestGetParameter("campo_valor", req) : "";
usuarioSoliciante = (Usuario)requestGetAttribute(USUARIO, request);
switch (action) {
case GET_TABLE:
actionGetTable(jsonResultArray);
resultado = jsonResultArray.toString();
break;
case EDITAR:
case EDIT:
// actionEdit();
break;
case EXCLUIR:
case DELETAR:
actionRemove();
break;
case REMOVER:
actionRemove();
break;
case INSERT:
case INSERIR:
case PERSIST:
case SAVE:
actionInsert();
break;
}
} catch (Exception e) {
jsonResult.put(SUCCESS, false);
JSONObject errors = new JSONObject();
errors.put(REASON, e.getMessage());
jsonResult.put(ERRORS, errors);
}
if (StringUtils.isBlank(resultado)) {
resultado = jsonResult.toString();
}
if (StringUtils.isBlank(resultado)) {
JSONObject errors = new JSONObject();
jsonResult.put(SUCCESS, false);
errors.put(REASON, "Nenhum resultado ao realizar a pesquisa.");
jsonResult.put(ERRORS, errors);
}
response.setContentType("text/plain");
response.setCharacterEncoding("utf-8");
response.setHeader("Access-Control-Allow-Origin", "*");
response.getWriter().print(resultado);
}
Thank you