Wikipedia Woes: Can Someone Troubleshoot My Ajax?

I’m having issues with the Wikipedia Viewer challenge. I know my search value works, because window.open(searchUrl) opens the json that I want. I just can’t seem to get the json or do anything with it using ajax, and my callback function is never being called.

Can someone explain what’s going on here?

Hi!
When your type text and click button or type enter it involve submit, your text value was sent to somewhere and your page refreshes. After refresh you see a new page without data like it was to load at first time.
You need to add preven refresh pages in your function setSearchVal()
event.preventDefault();

And then in function

function displayResults(data){
	$("#results").html(data);
}

you need extract text from data and pass it in html().
At that moment data is complex object not a string, that’s why it does not work.

1 Like