Following code is not working and not returning proper result.
function test(file) {
var uri = "http://localhost/test.php";
var xhr = new XMLHttpRequest();
var result="done";
xhr.open("POST", uri, true);
xhr.send();
xhr.onloadend=function()
{
result=xhr.responseText;
return result;
}
}
Is it wrong to return from event handlers or it just returns result back to test function?