I want to write a javascript function, that will make an ajax request to PHP script and returns it's result. That's how it looks:
function myjsfunc(some_data)
{
$.post(
"/myscript.php",
{ some_data: some_data },
function(response)
{
result = response;
}
);
return result;
}
The problem is, that result is always undefined. This might be because variable result is not in myjsfunc namespace? Or it is because success function result is received way after the main function is processed?
Anyway, how can I get desired result? Is there a way?