Need help retrieving JSON from Wikipedia API [Solved]

Need help retrieving JSON from Wikipedia API [Solved]
0

#1

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!


#2

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=?


#3

@jenovs Thanks! That works perfectly.


#4

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


#5

It requests jsonp to get around cross origin issues:


#6

@JacksonBates Thanks for clearing my confusion!