0
Dear colleagues.
I have a button on the bootstrap:
<button class="btn btn-xs btn-primary active" name="Botao" value="Ativar" id="ativar">Ativar</button>
I would like that by clicking this button, the status was changed to Deactivate, but without refreshing the page. I’m using the code below to direct to the page that makes the change, but it doesn’t seem to be going. See:
$(document).ready(function() {
$('#ativar').click(function() {
var valor = $(this).attr('value');
$.ajax ({
type: "POST",
url: "alterar.php?Key="+valor,
data: datastring
})
});
});
The change in PHP is OK when I go straight to the change.php page, but from the button it seems that you are not seeing the page.
I recommend reading http://api.jquery.com/jquery.ajax/ part of
success
.– Guilherme Lautert
What page is this Javascript running on? Do you want to change the status on the same page or on future pages?
– Sergio