I've been dealing for half the day with this. My function is not working. It worked at one point and now I can't figure out how to go back. This is my HTML code
<a href="#" onclick="updateDB('<?php echo $a; ?>','<?php echo $b; ?>','<?php echo $c; ?>','<?php echo
$d; ?>','<?php echo $e; ?>','<?php echo $f; ?>','<?php echo $g; ?>','<?php echo $h; ?
>','<?php echo $i; ?>','<?php echo $j; ?>','<?php echo $k; ?>')">Test</a>
Here is my javascript code
<script>
$(function() {
function updateDB(a,b,c,d,e,f,g,h,i,j,k)
{
$.post("update.php",
{ a:a,b:b,c:c,d:d,e:e,f:f,g:g,h:h,i:i,j:j,k:k
});
alert("Finally");
}
}
</script>
I can't get it to say Finally.
Any help is greatly appreciated.
Thanks,
implode()
onclick="updatedb(<?= implode(',', array_map('json_encode', array($a, $b, $c, $d, $e...))) ?>"
would be safer, as well. If any of those values is null, just echoing them into the page will make the JS syntax invalid. And that's not even going into what happens if they contain strings, quotes and HTML.