Working on my Wikipedia Viewer and was able to get the search term to show results on my page. Trouble is, I’m having a hard time figuring out how to get the information from the array so I can show the extracts from my search query. I have a feeling it has something to do with the way I set up my for loop, but I’m not entirely sure.
I changed the URL to what I had. Yours seemed to be giving back results in a different format. I don’t know why. the results didn’t look like what a JSON looks like to me (based on my limited understanding). I wrapped your query in encodeURI() - a good idea so some strange input (like a space) doesn’t screw up your search.
This yields back a JSON with several arrays. array 1 is the titles, 2 the descriptions, and 3 the URLs. You can get a closer look in your console.
This definitely has helped! I didn’t have the part where ‘&profile=fuzzy’, so I’ll have to look up what that means. But at least now I have results I can actually read.
directly under the below line of code place the following …
console.log("\n\njson[3], array of page URLs…\n");
var text ="<h2> Results for: " + query + "</h2> <br/>"+json[2]+"</p" $(’#results’).append(text);
Lol think your working on it as im checking it … so add below the text … in-between the lines above … … should have said add the text in bold above thats in between the lines … under text below … you can then remove that text below as well.
@JohnL3: Thanks for your help! This actually did what I wanted it to do, which is show the urls on the page.
Any ideas on how to get them to show up as a list? I’m thinking I need to do a loop to get them to show up correctly. Or maybe a “span” within the “p” tag to separate out the values.
I’m not sure. I think I need a break from this for the day since I’ve been working on it for almost 4 hours. But I’m making progress, so thank you again.
heres a quick bit of code to help you … as im going off my computor for a while but you should be able to make a start with this … plus look up … append … http://api.jquery.com/append/
Check out this quick repl first https://repl.it/GZc3/1