0
I cannot enter the success of ajax with this function. The function works, that is, calls the double click. The first Alert is ok, but the second is not fired.
$('#nmUsuario').on("dblclick", '.clique', function() {
alert('Alô, tudo bem?');
var obj = {};
$('tr').each(function () {
obj = {
_nivel: $(this).find('td').eq(0).text,
_nome: $(this).find('td').eq(1).text,
_usuario: $(this).find('td').eq(2).text
}
})
$.ajax({
url: '/CadastroAcesso/CarregaDadosPagina',
datatype: 'json',
contentType: 'application/json;charset=utf-8',
type: 'POST',
data: obj,
success: function(data){
alert('Alô, tudo bem 1?');
},
error: function(error){
}
})
})
Doing my tests, I saw that this is wrong:
$('tr').each(function () {
obj = {
_nivel: $(this).find('td').eq(0).text,
_nome: $(this).find('td').eq(1).text,
_usuario: $(this).find('td').eq(2).text
}
})
Is the error function called? There are several ways an ajax call fails, and without knowing what the
/CadastroAcesso/CarregaDadosPagina
makes it hard to know.– carlosfigueira
Another thing: you define Content-Type as JSON, but the data is sent as an object (which by default is serialized as form data). Exchange the
data: obj
fordata: JSON.stringify(obj)
. And see if the error function is called with more information on why the success is not.– carlosfigueira