I thought ajax was the same orgina?

I am confused about the same orgin domain policy with jquery ajax. If I make a request to get the url with jquery, I can return the results. What am I missing? I thought this was limited to the same policy.

    $(function () {
        var data;                     

      var x =   $.ajax({

            dataType: 'json', 
            url: 'http://jsonplaceholder.typicode.com/posts', 
            data: data, 
            success: function(){ console.log("true");}, 
            failure: function(){console.log("failed");}
        });


      console.log(x);

    });
+4
source share
1 answer

See this page .

The API can be obtained from your development environment through CORS or JSONP.

, , -, , CORS ( ), JSONP, , , . .ajax() dataType: 'json' , CORS. JSONP dataType: 'jsonp'.

CORS JSONP - , . , , , , . CORS JSONP .

+3

All Articles