<script>
function user_pro(useron){
$.post("userprofile.php", { useron:useron } );
document.location.href="userprofile.php";
}
$(document).on('click','#userprofile',function(){
var useron=$(this).data('id4');
user_pro(useron);
});
</script>
i am trying to send data to the page "userprofile.php" through the jquery ajax .post() when i click a button with id 'userprofile'. i have stored the username of the user(which i retrieved from my database in data-id4 attribute ). i want to send this username to my userprofile.php page and display his profile(like dp,status and all...). the .data('id4') method is working fine as i am able to store data in the variable useron . but i am not able to send the data to userprofile.php . and i also simultaneous want to be directed to that page when i click the button with id="userprofile".
<a data-id4='".$row['username']."' id='userprofile' class='w3-btn w3-teal w3-hover-indigo'>profile</a>
this is the html element. the html is inside the echo tag of of a php page(that is why those quotes).
can somebody plz help me out here . thanks in advance :) .