I am trying to get response from php echo statement but I am not getting any response, my code seems fine but I don't know why it doesn't work
test.php
<?php echo "test" ?>
dashboard.php
<script type="text/javascript">
function loadlink(){
$.ajax({
url: 'test.php',
success: function (response) {
alert("Hello"),
document.getElementById("links").innerHTML=response;
}
});
}
loadlink(); // This will run on page load
setInterval(function(){
loadlink() // this will run after every 5 seconds
}, 5000);
</script>
<div id="links"></div>
I am testing on my localhost, I do not get any response when I open the page
I have fixed the error, I debugged using google chrome, the code is correct but apparently i did not declare java script before the code