I want to send HTTP request like a simple request for "http://google.com/" and then print the HTTP response headers on screen. How can it be done? I want the base code so that I can use it to send more complex GET and POST requests.
<html>
<body>
<script type="text/javascript">
function sendgetreq()
{
var req = new XMLHttpRequest();
req.open('GET', "https://www.google.com/search?q=asd", true);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
//document.write("Headers are:"+headers);
alert(headers);
}
</script>
<INPUT TYPE=BUTTON OnClick="sendgetreq();" VALUE="Send Request">
</body>
</html>
This shows me an empty popup box.