I'm sorry I am very new to programming especially java script. Please help me.
I'm using php to get and update the data from db. And I'm trying to get my data from database using JavaScript function onclick
but I kept getting an the same error.
First is I have my data already fetched.
And stored it inside my variable $data
but I applied json_encode
as per the video tutorial I watched but unfortunately my code didn't worked. I don't know why.
This is how I initiates my codes:
//This is foreach loop with a variable of $user where all the data has been stored in array(I'm not sure), before the line of this code below.
$data = json_encode($user, true);
//In my link/href where I'm getting an error that my $data is not defined.
<a href='javascript:getUpdateUser($data);' id='edit'> EDIT </a>
//and my script
<script>
function getUpdateUser(user) {
alert(user);
}
</script>