I am currently taking the Udacity Front-End Web Developer Nanodegree course, and I'm on the AJAX course.
My project is to take an addrress and:
- load New York Times articles
- load a background image from Google Streetview
- load relevant articles from Wikipedia
I have the first two done. The third requires either jsonp
or CORS
, and my question is: why?
What is the difference between these first two calls that work just fine:
http://api.nytimes.com/svc/search/v2/articlesearch.json?q=somecity&api-key=...
http://maps.googleapis.com/maps/api/streetview?size=600x400&location=...
and this one that fails?
https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=...
Note: The above urls are:
- searched for articles using
jQuery.getJSON()
(NY Times) - used as the
src
for background image (Google StreetView) - searched for relevant articles using
jQuery.ajax()
(wikipedia)
The error message from the WikiPedia attempt is:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://...' is therefore not allowed access.
To reiterate: What scenario is wikipedia trying to prevent?
Update:
The actual urls used are:
http://api.nytimes.com/svc/search/v2/articlesearch.json?q=somecity%20somestate&api-key=...
http://maps.googleapis.com/maps/api/streetview?size=600x400&location=999%20main%20st,%20somecity%20somestate
https://en.wikipedcwodecgia.org/w/api.php?action=query&format=json&list=search&srsearch=somecity%20somestate&callback=jQuery111107555398044642061_1459988112375&_=1459988112376