1
I’m creating a click counter on the link this way:
<a href="#" onclick="return chamarPhpAjax();"></a>
That by clicking on 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;
}
By Ajax, the data is sent via POST to the page "meuajax.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 cannot receive by parameter the data to put in var so = ""; var name = "";
Ajax. How do I pass the data to onclick
, more or less like this:
<a href="#" onclick="return chamarPhpAjax(<?php $dados->so;?> , <?php $dados->name;?> );"></a>
And receive these parameters in Ajax?
You can rephrase your question by deleting snippets that don’t work in context?
– Sam
OK I’ll try a better explanation
– diogo Dsa