Good afternoon,
Edited:
From what I understand you want to give an alert to the user that what he searched for was not found. You should have a page like www.lovedevelopment.com.br/vusca.php? q=0 ( q=0 and did not find the result ). In this case we will see how it would look in php.
<?php
//Analisando o caso com a URL ww.lovedevelopment.com.br/vusca.php?q=0
//vamos primeiro colocar em uma variável o resultado
$testa_minha_busca = $_GET['q'];
//Depois vamos testar se o resultado veio igual a 0
if ( $testa_minha_busca == 0 ) {
//Se for encontrado vamos mandar um alerta
echo "<script>alert('Sua busca tá osso man!');</script>";
// Em seguida vamos mandar ele para home e 3 segundos
header( "refresh:3;url=home.php" );
}
?>
I saw that one of the tips they gave you was to use AJAX. Let’s first start using this "Disinfectant".
What is it ?
Method that opens a window to pass client-side information to the server-side.
And when do I wear this ?
I want to save my data in a mysql database and I have a file that inserts it into the database an Insert.php only that the data is coming from a client-side form and I don’t want to use the PHP POST.
Let’s take an example in a search. I have a file that calls check_de_busca.php and I want but I want the search to be dynamic and without Reload, and the data comes from javascript. And when the result is null it returns this file calls check_de_search.php.
<script>
$(document).ready(function() {
//Quando clicar na busca
$('botao_buca').click(function() {
//chama o AJAX
$.ajax({
//vamos postar
type: "post",
//Para o Arquivo abaixo
url: "check_de_busca.php",
//A variável do javascript que eu quero passar para o PHP é termo de busca
data: "busca"+termo_de_busca,
//Asynchrono
async: true,
//Se ele der sucesso da requisição e for 0 avisa os truta
success: function(result) {
if (result == 0) {
alert('Sua busca tá osso man!');
}
},
});
});
});
</script>
Just adjust your variables and Divs. And an additional interface tip if you’re going to send an alert ( http://t4t5.github.io/sweetalert/ ).
Thank you,
I’m available
Here worked normal the first code, see in your devTool at
console
if an error appears.– RFL
php is the server-side language and javascript is the client-side (browser). You should use ajax for this.
– rray
Vish do not know how to use ajax as q I can do it this way? could you explain me rray?
– Leonardo Costa
The use of ajax seems to have nothing to do with the case..
– Daniel Omine
I think he just wants a custom dialogbox... but I think the use of
$.alert
because it does not exist natively. And also the fact of parsing a static code in PHP, seems meaningless or unnecessary.– Daniel Omine
If you wanted a "custom jquery Alert", you should look for the method
dialog()
: http://jsfiddle.net/eraj2587/Pm5Fr/14/– Daniel Omine
people I have already found a jquery plugin that makes the custom Alert I tested it using only javascript or better saying the jquery it is running this learning the bunitinha Alert but I want to implement it in an echo in php and can not and that I want not dialog box.
– Leonardo Costa