# Javascript return doesn't work?



## aximbigfan (Mar 30, 2008)

I have been trying for a long time, I just want this function to return a var, but no matter what, it doesn't work.


```
function ajax(url)
{
var http = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

http.onreadystatechange = function()
{
if (http.readyState == 4)
{
if (http.status == 200)
{
return http.responseText;
}
else
{
alert("AJAX Error! \nReturned Text: "+ http.statusText);
}
}
}

http.open("GET" ,url , true);
http.send(null);
}
```

Anyone?

Thanks,
Chris


----------

