Data retrieval error in Jquery
- by Ben
I'm trying to retrieve data from a php file named return that contains <?php
echo 'here is a string';
?>. I'm doing this through an html file containing `
div { color:blue; }
span { color:red; }
var x;
$.get("return.php", function(data){
x = data;
})
function showAlert() {alert(x);}
$(document).ready(function(){
alert(x);
});
` When the button is clicked it retrieves and displays the code fine, but on the page loading, it displays "undefined" instead of the data in return.php. Any solutions?