0

I'm trying to load an external html page using ajax, but I can't get a response like:

example.com

My code for the request is:

$.ajax({
    type: "GET",
    url: "https://login.yahoo.com/",
    dataType: "json",
}).success( function( data ) {
    $( 'div.ajax-field' ).html( data );
});

I always get this error why?

MLHttpRequest cannot load https://login.yahoo.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:8000/dashboard' is therefore not allowed access.

Ivanka Todorova
  • 9,964
  • 16
  • 66
  • 103
Seeker
  • 1
  • 6
  • 1
    You can finde right answer for this question in this post http://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-ajax – A.Gharibyan Oct 16 '16 at 16:37
  • You've told it you're expecting to get JSON back by adding `dataType : "json"`, yet you're returning HTML, not that it matters, you can't load random websites with ajax because of the same-origin policy. – adeneo Oct 16 '16 at 16:37
  • Your error tells you what you need to know. Google it – j08691 Oct 16 '16 at 17:02

0 Answers0