I have the following example:
My HTML file has this snippet of code:
<script>
$( "form" ).submit(function( event ){
event.preventDefault();
$.ajax({
url : 'funcoes.php',//url para acessar o arquivo
data: {id : 10},//parametros para a funcao
type : 'post',//PROTOCOLO DE ENVIO PODE SER GET/POST
dataType : 'json',//TIPO DO RETORNO JSON/TEXTO
success : function(data){//DATA É O VALOR RETORNADO
alert(data.valor);//VALOR INDICE DO ARRAY/JSON
},
});
});
</script>
I also have a file called funcoes.php with the following content:
<?php
function teste(){
echo json_encode(array('valor' => $_POST['id']));
}
function teste2(){
echo json_encode(array('valor' => $_POST['id']));
}
?>
What I would like to know is: How do I access the test1 (or test2) function? What do I have to pass as "parameter" in my HTML file so that it knows which of these two functions I want to execute?