1
I have a button Atualiza Conteudo
that if someone clicks does a refresh only in the div content
and does not update the entire page.
So far so good, it turns out that the nova_pagina.php
that I am including after the back click an example button that when being clicked it disappears, I used a function in javascript only that it does not work on index.php
.
How do I fix this and make that inside the index.php
also work?
index php.
<div id="content">
</div>
<input id="updateContent" type="button" value="Atualizar Conteudo" />
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
var url = 'nova_pagina.php';
var updateContent = document.getElementById("updateContent");
var content = document.getElementById("content");
updateContent.addEventListener("click", function (event) {
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.addEventListener("readystatechange", function (event) {
if (request.readyState == 4 && request.status == 200) {
content.innerHTML = request.responseText
}
});
request.send();
});
</script>
nova_pagina.php
<div class="mydiv">
<input type="button" class="esconderBotao" value="Esconder Botao" />
</div>
<script>
$(".mydiv").on("click", ".esconderBotao",function () {
$(".esconderBotao").css('display','none');
});
</script>
Dude, because you’re using jquery and doing ajax with pure js?
– Leandro RR