0
How do I update an element’s information div
with jQuery without necessarily reloading the page?
Ex.: Send a post
of a insert
and the information provided by insert
appear right on the div
pulling from the bench.
0
How do I update an element’s information div
with jQuery without necessarily reloading the page?
Ex.: Send a post
of a insert
and the information provided by insert
appear right on the div
pulling from the bench.
3
Use the function $.post
jquery:
$("#form").submit(function() { // QUANDO ENVIAR O FORM
var login = $("#login").val(); // VALOR DO LOGIN
var senha = $("#senha").val(); // VALOR DO INPUT SENHA
$.post('logar.php', { // FUNÇÃO POST, LOGAR.PHP FAZ A INSERÇÃO NO MYSQL
login: login,
senha: senha
}, function(resposta) {
$("#divresposta").html(resposta); // RESPOSTA
}, 'html');
return false;
});
2
Basically study the function $.ajax
:
$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});
Source: http://api.jquery.com/jquery.post/
You can do the following (I haven’t tested, but that’s basically it):
$.ajax( {
url: "insert_func.php",
type: "post",
data: { name: "bruce", age: 23 }, // dados que serão processados
success: function(response) {
$(".your-div-class").html(response);
}
});
Browser other questions tagged php jquery ajax
You are not signed in. Login or sign up in order to post.
You are giving an error on the line: $("#form"). Submit(Function() { // WHEN TO SUBMIT FORM var login = $("#login"). val(); // LOGIN VALUE var password = $("#password"). val(); // INPUT VALUE PASSWORD $.post('log in.php', { // POST FUNCTION, LOG in.PHP INSERTS INTO MYSQL login: login, password: password }, Function(reply) { $("#divreply"). html(reply); // REPLY } }, 'html'); //<<<<<<<<<<<< ERROR HERE Return false; });
– André Cabral
corrected!!! thank you!!!
– Alan PS