I have a system with several forms calling jQuery and ajax to solve the problems and register the data retrieved in the mysql database. Since I am a beginner, I am having problems due to lack of knowledge. What I learned:
<script src="jQuery"></script>
<script>
$(document).ready(function(){
$("#enviar").click(function() {
$nome = $("nome").val();
if(nome != "") { tratamento e banco } else { avisa o usuário }
});
});
</script>
<body>
<form action="" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" id="nome">
<input type="submit" id="enviar">
</form>
But now I have to process 20 variables, suddenly do functions to validate some and then with ajax send to the database and process all the messages. I can not write this script any way other than in an external .js file that will be left alone for this. I tried to create an external .js but when I click send the script it does not search the .js with the #enviar
parameter to start processing the form even though in form action
I call the file PHP
and put the jQuery inside of it.
Question: As when giving the action of the id enviar
in the submit of the form, it will fetch the external file and will process all this javascript. I am a beginner but I already have systems in PHP. Now, how do I call my external javascript?
I also tried to insert it at the top of the system thinking that it would be include
or require
as PHP
but totally unsuccessful.