2
i am creating a service system where there is a screen only to display the passwords that are being registered in the database.
The problem is that I can’t update the passwords in real time, because I’m calling them from another page, I just managed to use schemes to keep updating the page every certain time, I wonder if I can do this asynchronous along with ajax.
This is the code of the screen that calls the passwords
<script>
$(document).ready(function Att() {
$.ajax({
url: '../SenhaController',
data: 'json',
success: function (data) {
$.each(data.nomeNormal, function (idx, obj) {
$('#tabelaNorm').ready().append("<tr><td>" + obj.nomeNormal + "</td><tr>");
});
$.each(data.nomePref, function (idx, obj) {
$('#tabelaPref').ready().append("<tr><td>" + obj.nomePref + "</td><tr>");
});
}
});
});
</script>
And this is where I register the passwords
<script>
$(document).ready(function () {
$('#submit').click(function (event) {
var username = $('#name').val();
var senha = $("input[name='senha']:checked").val();
$.getJSON('../gerarSenha', {user: username, senha: senha}, function (resposta) {
$('#resultado').html(resposta.respostaNormal).fadeIn().delay(1000).fadeOut();
$('#resultado').html(resposta.respostaPref).fadeIn().delay(1000).fadeOut();
$('#name').val('');
});
});
});
</script>
Thank you in advance.
Sure want to use refresh?
– João Victor Gomes Moreira
http://answall.com/questions/38467/como-consultar-a-db-sem-refresh-e-writingos-relateds?rq=1 - Duplicate?
– João Victor Gomes Moreira
Not necessarily, I just need the password screen data to be updated as soon as I enter a new password into the database, the problem is that the password screen is on another page and I can’t do that, I’ve circled the forum with several similar problems but no equal
– Rafael Monteiro
All right, sorry for the mistake, I think it would be great to use this will help a lot of people, I preferred the question to see the answer later ;)
– João Victor Gomes Moreira
Let me get this straight, one page you enter the password in the database, the other page you search the passwords. But I wanted it to be in "real time"?
– lionbtt
That’s right lionbtt, I have a page that I register these passwords like a "Triage", the page that displays the passwords they only search via ajax, so I wanted this page to update in real time, if you need to update the page to appear next
– Rafael Monteiro
@Rafaelmonteiro, some frameworks like Meteorjs handle this type of scenario very well, in any case you will need to make a change on the Server side to achieve the expected result. So, what Voce is using on the server side?
– Tobias Mesquita
I will give a research on this Meteorjs, I am working with java treatment by Servlet
– Rafael Monteiro