0

I'm trying the following code in my browser's console.

$.ajax({ 
    type: 'GET',
    url: 'http://stackoverflow.com/', 
    dataType: 'html', 
    success: function() { 
        console.log("Yes, this works."); 
    } 
});

Why don't I receive my message in the console?

I do receive the following code.

Object { readyState=1, getResponseHeader=function(), getAllResponseHeaders=function(), more...}
Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232

1 Answers1

0

If you control both domains and have access to server configuration, you can enable Cross Origin Resource Sharing (CORS) to allow AJAX requests from one domain to access the other. The steps for enabling CORS depends on your specific web server (e.g. Apache, node, nginx, IIS, etc.) Dr. Google should be able to give you the specifics.

And to answer your specific question, you don't see a console message because the AJAX request never succeeds.

Stephen Thomas
  • 13,843
  • 2
  • 32
  • 53