0

I need to perform the following GET request,

telnet somesite.com 80
GET /index.html HTTP/1.0

using javascript, jQuery.

I've tried to follow the instructions in this site in particular the following code:

$.ajax({
  url: 'http://somesite.com',
  success:function(data){
    alert(data);
  }
});

but It doesn't work!

Where am I wrong?

dp.carlo
  • 597
  • 2
  • 11
  • 28

3 Answers3

1

Try this one:

$.ajax({
        type: "GET",  
         url: "http://somesite.com",
     timeout: 300000,
 contentType: "application/json; charset=utf-8",
     success: success,
       error: failure
});

function failure(response) {
    alert(response);
}
function success(response) {
    alert(response);
}
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Priya Gund
  • 156
  • 5
1

by your code im assuming you are doing a cross domain ajax request. Which are automatically blocked by the browser.

you can either use the allow domain header using Cors see this Cross Domain Get Request in JS/JQuery

or switch to JSONP

Community
  • 1
  • 1
Parv Sharma
  • 12,581
  • 4
  • 48
  • 80
1

If you want to perform a cross domain request try this

Working DEMO

You can use this in your head tag

<script src="https://rawgithub.com/IonicaBizau/jQuery-cross-domain-requests/master/js/jquery.xdomainajax.js">
</script> 

code

$.ajax({
    url: 'http://somsite.com', // Or your web page link
    type: 'GET',
    success: function(res) {
      alert(res);
    }
  });
SarathSprakash
  • 4,614
  • 2
  • 19
  • 35