when i call Javascript function first time it work properly but second time it get error like
Uncaught TypeError: profile is not a function at HTMLImageElement.onclick
why it happening?
try to write function in head section of html as well as js file but didn't working!
function profile_detail(){
xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost/CI-social-media/index.php/profile_detail", false);
xhr.onload = () => {
if (xhr.status == 200) {
if (xhr.response) {
profile = JSON.parse(xhr.responseText);
// console.log(xhr.response);
console.log(xhr.response);
console.log(profile);
// document.getElementById("profile_photo").innerHTML =xhr.response;
document.getElementById("profile_photo").src = profile[0]["profile"];
document.getElementById("profile_name").innerHTML = profile[0]["display_name"];
document.getElementById("username").innerHTML = "@"+ profile[0]["user_name"];
}
else {
alert("something want wrong try agin later")
}
}
else {
alert("Something Want Wrong Try agin");
}
}
xhr.send();
}
function profile(){
document.getElementById("request").style.display="none";
document.getElementById("friend_list").style.display="none";
document.getElementById("msg_section").style.display="none";
document.getElementById("friend_search").style.display="none";
document.getElementById("home_mains").style.display="none";
document.getElementById("search_friend_main").style.display="none";
document.getElementById("search1").style.display="none";
document.getElementById("rrprofile-card").style.display="flex";
profile_detail();
}