I started venturing on ajax and its coolness.
I managed to GET all the data from the ajax request but I wonder if you can request for a specific php variable to be retrieved.
I have the following code on HTML:
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<div id="textdiv">
<div id="counter"></div>
</div>
<script>
$("#textdiv").hover(function(){
$.get('ajax.php', function(data){
document.getElementById('counter').innerHTML = data;
});
});
</script>
And on the ajax.php I have the following:
<?php
$kate = "Kate is here";
echo $kate;
$jack = "Jack is here";
echo $jack;
?>
Of course hovering on textdiv now I get both data however I have the following questions: 1) Is it possible to request only $jack and how would the function look like? 2) Is my code a true ajax request vs $.ajax({...
Thank you, Oliver