Cosa voglio fare?
Al click sul link cliccami, voglio far partire una funzione in php, quindi lato server
In aspnet si usa per esempio
<a id="A1" runat="server" onServerClick="stampa">
Senza usare ajax si potrebbe fare ad esempio :
<?php
if($_POST['nomeMetodo'] == "stampa")
{
echo('Eccomi !');
}
?>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(nomeMetodo) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__NOMEMETODO.value = nomeMetodo;
theForm.submit();
}
}
//]]>
</script>
<form name="form1" method="post" action="Default.php" id="form1">
<div>
<input type="hidden" name="__NOMEMETODO" id="__NOMEMETODO" value="" />
<a id="A1" onclick="__doPostBack('stampa')">Cliccami</a>
Che ne pensi?
E' usata questa soluzione?