Can t get json data in Wikipedia Viewer


I m trying to access some json data, to log it but it doesn t work no matter what, I tried several URL’s even from wikipedia’s examples and no result, nothing happens. I tested my code on submit, it gets the query but when it tries to grab json data it gets stuck there. This is my code so far:

    var query = $("#query").val();
    var url = '' + query+ '&format=json&callback=?';
    $.getJSON(url, function(json){
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <div class="articles">
     <div class="random">
   <a href="" target="_blank">Click here for a random article</a>
  <form id="form" >
    <input type="search" id="query">
     <div class="close"></div>
    <p>click icon to search</p>


Can you share the html too?

This is the html for now i edited the post

Thanks. One quick idea: do you have jquery in your project?

yeah i m using this and also this from bootstrap
I can console the value from my input so the issue is with json. I think it has to do with cross origin issue

I added e.preventDefault(); after submit and now it works. Apparently this was the cause

I added the action attribute to your input form, and now I can see the response for my query, but it looks like it’s coming back in JS, not XHR.


My guess is that you need to add the response data type in your api call. I’ll play with it for a bit longer and let you know if I find anything.

Oh, great! You got it!

thank you for your help

Don’t know if I actually helped! But happy to try!

Damn their API is horrible… so messed up