Need help retrieving JSON from Wikipedia API [Solved]

Hi all,
I have just begun the ‘wikipedia viewer’ project. Right now I am just trying to display the first search title on the page. So far I just have the search-input field, a search button and a random article button on my page(no CSS or other fancy stuff yet)

Problem:
No matter what I do, I can’t get the first search result on the screen. My codepen link is http://codepen.io/aks2161989/full/WxLoya/

Can anyone tell me what’s wrong with my code? Thanks in advance!

Add &callback=? at the end of getJSON
$.getJSON("https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles="+searchTerm+"&rvprop=content&format=json&rvsection=0&rvparse=1&callback=?

2 Likes

@jenovs Thanks! That works perfectly.

@jenovs Can you tell me what is the role of &callback=? ?

1 Like

It requests jsonp to get around cross origin issues:

2 Likes

@JacksonBates Thanks for clearing my confusion!