Wikipedia viewer json problem

Wikipedia viewer json problem
0.0 0

#1

okay that’s strange and it happened for second time
i made simple page for wikipedia viewer
and when i start to use $.getJSON() it stop
so that is my project https://codepen.io/ayman-ayman/pen/qPvzNE

if i wrote
$("#container").html(foo);
before the call of $.getJSON()it work fine or after also
but inside the call it doesn’t work and i don’t know why
with weather api also this happened and i solve it by
use of toString() here every value i used string
and i try to use
$("#container").html(“anything”);
and not work also so what is my wrong please


#2

Forms refresh the page by default when you hit the Submit button (as in this case). Modify your click handler to prevent refreshing like so:

$('#btn').click(function(event) {
  event.preventDefault();

  // ... rest of your code ...
});

After that, you’ll encounter a CORS issue with the JSON request. You can add origin=* in the Wikipedia URL parameters to allow the request.

After that, you’ll encounter a logic error, but I’ll leave it to you to fix it :wink:


#3

will thank you
i change $.getjson to $.jax() and it respond to request
but it return string now not object at all and i don’t understand why
i use alert (typeof(json)) to know that
why that


#4

I think you missed this:

$.ajax({
  url: req,
  // ...
});

#5

thank you
you helped me alot