My understanding is that if it is a cross-domain request, we are supposed to set dataType to “jsonp”. Which I did, but then it did not work. I got the following error message in the console:
Refused to execute script from ‘http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_p…page]=1&callback=jQuery31105215916043980608_1487877164531&=1487877164532’ because its MIME type (‘application/json’) is not executable, and strict MIME type checking is enabled.
But when I set it to “json”, it worked.
Can anyone explain why?
There’s another, newer way of making cross-origin request: CORS. If a provider (server) supports it, a client can just send normal requests without any additional setup. That’s why your request succeeded.
If you want to use jsonp, you need to provide an additional parameter ( _jsonp) to your query string to inform the provider that’s the format you want to use (as you can read in api docs).