Below code is working properly now. But if I replace 'text.txt' with 'http://google.com' isn't showing anything, nor displaying an error.
What am I doing wrong?
I need this code to get content of an url to a string, on client side.
Thakns.
<script type="text/javascript">
var webUrl = 'text.txt';
var queryString = '';
var xmlText = getAjaxValues(webUrl, queryString);
window.alert(xmlText);
document.write(xmlText);
function getAjaxValues(webUrl, queryString)
{
var xmlHttpObject = new XMLHttpRequest();
xmlHttpObject.open("GET", webUrl, false);
xmlHttpObject.send();
var xmlText = xmlHttpObject.responseText;
return xmlText;
}
</script>