Trouble retrieving json

hey guys, I’m working on the weather app and I’m trying to retrieve the city given the lat & long.

function getCity(){
  $.getJSON(",-2.479539&sensor=true", function(json) {

This site verifies the api is good for json-retrieval. However, when I test it in html body, i.e

<button onclick="getCity()">City</button>
<p id="demo"></p>

Nothing shows up in the browser :frowning:

Any ideas on what’s going on? I think I need to involve error handling somewhere but not quite sure where to do so. Thanks for the help

##EDIT: I fixed it. I had to disable my uBlock extension :expressionless:

hey! I checked your code on codepen…it’s showing the json content on clicking the button.There seems no problem!

1 Like

Check your console for errors and make sure you have jQuery enabled ($.getJSON is a jQuery call)

1 Like

@Faizahmadfaiz Really? When I click the city button nothing shows up for me. Location works however.

I made the getCity function as simple as possible…

function getCity(){
    $.getJSON("", function(json) {

As you can see, when I click getCity, nothing gets printed. I also tried console.log() while inside the getJSON and nothing shows up on console…

it will show

Still nothing :frowning:
I’m gonna look into error handling to see if I can debug the issue

@gouldie Yes I have jquery enabled, I think it may be an issue with the api url.

Can someone explain why at times a quote will show up, but at other times nothing shows up (at least for me)? I think it’s related to my problem with the weather api

hey I understand the problem! I think you are opening the codepen with https://. Open your codepen in http .It will work!

@Faizahmadfaiz I finally figured it out. I’m on chrome and I’m using an adblocker called uBlock. All I had to do was disable it and the text showed up. goddamn lol.

However, when I was looking at other people’s weather apps, ublock was activated and their app still showed me the weather! So confusing…