1
I have a button reset to delete values from a form.
It turns out that I wanted to delete the session variable in PHP and I can’t do it, it can be by jQuery.
This is the code I have:
document.getElementById("pesquisa").reset();
1
I have a button reset to delete values from a form.
It turns out that I wanted to delete the session variable in PHP and I can’t do it, it can be by jQuery.
This is the code I have:
document.getElementById("pesquisa").reset();
1
Creates a function that will call the reset that you currently use and will clean the Session through Ajax, all you need to do is call the function on the button where the type
will be Button
and the onclick
you pass the name of the created function.
PHP code:
Try {
// limpa a sessão
$_SESSION = array();
// destroy a sessão
session_destroy();
echo "sucesso";
}
cacth(Exception $e) {
echo "erro";
}
Code jQuery:
function resetSession() {
$("pesquisa").reset();
$.ajax({
url: "Acao.php",
method: "POST",
data: {},
async: false,
cache: false,
success: function (data) {
if (data != "sucesso") {
Alert("Session não finalizada!");
}
else {
Alert("Session finalizada!");
}
},
error: function () {
Alert("Ocorreu uma falha!";
}
});
}
Browser other questions tagged php jquery
You are not signed in. Login or sign up in order to post.