I am trying to use ajax to get information from my server. the page xxx.php is a page with only 123 written on it. However, when I want to return the content of that page, it returns null.
function myFunct(){
$.ajax({
url: 'xxx.php',
success: function(data) {
return data;
}
});
}
var data = myFunct(); //nothing.
Please note that ajax is ‘asynchronous’. So, the response to your server call may not received by the time myFunct() completes execution.
You may put the logic of process the data from your server call in the ‘success’ of ajax.