Wikipedia Viewer help plzzzzzzzzzzzzzzz

Wikipedia Viewer help plzzzzzzzzzzzzzzz
0.0 0

#1

Hello.
I dont understand why my code is not working. When I try to search it doesn’t respond.
If some one can help me.
I have posted a link to my code pen down below.
Thank you
Also if any one has any tips,recommendations of videos etc on how to create an animation in js or css that would be much predicated.
Thank you


#2
$(docyment).ready

You’ve got a typo there.


#3

Thnak you.
I have fixed it and still not responding.


#4

You’ve got at least one more typo:

var searchTerm=$('#searchTerm').vsl();

There may be more, and you should be fishing them out. Open up your browser’s console and use your app. When you see red or yellow text in the console, it means there’s something wrong. Fix all the typos you can find and if you’re still having problems after that, come back here with another question.


#5

for some odd reason my console is blank?
Any tips?


#6

Your console may be filtering out warnings. Check the top of your console window for something like “Filter”. Here’s what it looks like in Firefox:

57%20AM

Right now, I’m not seeing any errors in the console, though.


#7

thank you it works
now i have another issue where if i search for a word i get the error message.


#8

This is the api call that I used, which worked: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=" + keyword + "&prop=info&inprop=url&utf8=&format=json. You should change keyword to searchterm to match your variable.


#9

Thank you .
I used the api that you have provided but still when i use the Search bar and press search it gives me the error Message


#10

This is the function that I call when the user clicks on the button:

function ajax (keyword) {
  $.ajax({ 
    url: "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=" + keyword + "&prop=info&inprop=url&utf8=&format=json",

   dataType: "jsonp",
   success: function(response) {
       console.log(response.query);
       if (response.query.searchinfo.totalhits === 0) {
         showError(keyword);
       }
       else {
         showResults(response);
       }
  },
   error: function () {
    alert("Error retrieving search results, please refresh the page");
   }

 });
}

I called this function in response to an element click:

      $("#searchButton").on("click", function () {
        ajax($("#myInput").val());
      });

#11

Like in @jonathn6’s example, setting the dataType to “jsonp” will correct your immediate problem. You should also remove async: false. It’s not doing you any favors and it’s automatically disabled when you use JSONP anyways.


#12

thank you
I did all that but still no go.
What am i doning wrong ?


#13

Open your console! Don’t rely on Codepen’s console because it doesn’t tell you much.

57%20AM

Take a look at the data that’s coming in and make sure you understand the format. You’re very close to being done!


#14

it works
Thank you so much