I'm creating a click counter on the link this way:
<a href="#" onclick="return chamarPhpAjax();"></a>
That when clicking the link calls the function:
function chamarPhpAjax() {
var so = "";
var name = "";
$.ajax({
url:'/assets/classes/meuajax.php',
type: 'post',
data: { 'so': so, 'name': name }
});
return false;
}
For Ajax, the data is sent via POST to the page "myajax.php":
<?php
function testeOnclick() {
$so = $_POST['so'];
$name = $_POST['name'] ;
include_once "../config/Config.inc.php";
$pdo->query("UPDATE '$so' SET downloads = downloads +1 WHERE name = '$name' ");
}
testeOnclick();
?>
The problem is that I can not get the data to put in var so = ""; var name = "";
of Ajax per parameter. How do I pass the data in onclick
, going something like this:
<a href="#" onclick="return chamarPhpAjax(<?php $dados->so;?> , <?php $dados->name;?> );"></a>
And receive these parameters in Ajax?