0
I’m trying to do a function with jQuery (I saw it once in jQuery), where when clicking on a link, runs a php page in the background. Note: I am not good with jQuery.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
$(document).ready(function(){
$("#botao").click(function(){
//apenas executa uma página após o click do usuário final em um botão.
//nada é feito além de execução da página, nenhum aviso, nada.
//não é enviado qualquer parâmetro para para pagina.php.
//permanece na página atual sem qualquer alteração.
$função_que_executa_pagina: 'pagina.php';
});
});
</script>
</head>
<body>
<!--botão que executa o código-->
<a id="botao" href="#">
</body>
</html>
I tried so it didn’t work.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
$('#botao').on('click', function () {
url = 'pagina.php';
var aClasse = this.id;
$.ajax({
url: url,
}
});
});
</script>
</head>
<body>
<!--botão que executa o código-->
<a id="botao" href="#">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js">
</body>
</script>
</html>
If anyone can help, I’d appreciate it.
What exactly is your problem? Edit your question and provide us with more information like the corresponding HTML, where you define this variable Purl...
– Bruno Augusto
Márcio, where the variable comes from
purl
? What you want to pass to PHP?– Sergio
What do you want with
url : 'pagina.php'
? What do you expect me to do? If you don’t know say you don’t know, but it’s hard to figure out what you want...– Sergio
Yes, I took this code on the Internet and tried to edit, because I don’t understand jQuery (no javascript).
– Márcio Teixeira
want to run page.php so that it changes the notification status to 'viewed'.
– Márcio Teixeira
I have something exactly like Facebook notifications, when clicking to see, already mark as viewed.
– Márcio Teixeira
I also wish it was duplicated, but it has nothing to do with the other post. I don’t want to load a page on another, just run a php page without leaving the page you are on, without the end user perception.
– Márcio Teixeira
It’s exactly the same thing @Márcioteixeira
– Jorge B.
Use Ajax! There is no page update this way, the browser makes the request without giving Reload.
– Marcelo Aymone
I reread the question and did not identify similarity. I know that I am not clear, because I do not know the commands of jQuery. I changed the question to try to clarify.
– Márcio Teixeira
How to do in Ajax? Marcelo Aymone.
– Márcio Teixeira
It is not an exact duplicate at all, but the answers there serve almost entirely for your case. Use an ajax call that is in the accepted answer of the other question, and change only what is within the function of
success
(what is to be done after receiving a php response; it may be nothing).– bfavaretto
Exactly how you put @bfavaretto...
– Marcelo Aymone
I think his problem is that he declared the reference to jQuery after using the function
$
.– Wakim