1
good personal evening I am creating a system and in it I make a dynamic request with ajax to fetch names of customers I have a link that opens a modal with the information to give update ,as when I click Refresh the page
function exibirConteudo(id) {
$('#myModal').modal('show');
// Verificando Browser
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
}
else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
// Arquivo PHP juntamento com a id da noticia (método GET)
var url = "liks.php?recordID="+id;
req.open("GET", url, true);
req.onreadystatechange = function() {
// Exibe a mensagem "Aguarde..." enquanto carrega
if(req.readyState == 1) {
document.getElementById('conteudoModal').innerHTML = 'Aguarde...';
}
if(req.readyState == 4 && req.status == 200) {
// Resposta retornada pelo exibir.php
var resposta = req.responseText;
// Abaixo colocamos a resposta na div conteudo
document.getElementById('conteudoModal').innerHTML = resposta;
}
}
req.send(null);
}
this is my save button that opens in modal
<input type="hidden" name="id_cli" value="<?php echo $row['id_cli']; ?>" />
<button class="btn btn-success" name="submit" type="submit">
Salvar
</button>
</form>
and this is my ajax request for the save button
$("#form_cli").submit(function(e) {
var url2 = "con_cliente.php"
var url = "update/update_cli.php";
if (confirm('Tem certeza que quer cadastrar o cliente?')){
$.ajax({
type: "POST",
url: url,
data: $("#form_cli").serialize(),
success: function(data)
{
$("#alterafade").fadeOut(800, function(){
$("#alterafade").load(url2).fadeIn().delay(2000);
});
//utilizar o dado retornado para alterar algum dado da tela.
}
});
}
e.preventDefault();// esse comando serve para previnir que o form realmente realize o submit e atualize a tela.
});
When I click to save it from refresh and the page address is the way it is