i'm trying to call a javascript function from a tag , but for some reasons i can't get it work i don't get an alert at all, if i delete the call of function goToprofile i get the json readin right , does the place of the function affects if he can read it ?
my html page :
<!DOCTYPE html>
<html>
<head>
<script>
function load() {
$.getJSON("jsons/followers.json", function(json) {
followers = json;
for(var k in followers.followers){
if(k=='Admin')
{
for(var j in followers.followers[k]){
$('#contentFollow').append('<li><a href="#"
id="'+followers.followers[k][j]+'"
onclick="goToprofile('+followers.followers[k][j]')">'
+followers.followers[k][j]+'<br>'+'</a></li>');
$('#contentFollow').append("<br>___________<br>");
}
}
}
});
}
function goToprofile(Theuser)
{
alert(Theuser)
}
<script>
</head>
<body onload="load()">
<ul>
<li id="dropdownFollowing" style="position:absolute;left:530px;Top:0;">
<a class="dropbtn" ><img src="images/user.png"></a>
<div class="dropdown-content" id="contentFollow">
</div>
</li>
</body>
my json file :
{
"followers": {
"Admin": ["ilan shemon","lian jack","lele robit"]
}
}
without calling goToprofile function i get this html ,but adding the call of the function it doesn't show anything: