Rohan Akut Rohan Akut -4 years ago 53
Javascript Question

Why is the API data is not loading even after using getJSON call?

I want to do a simple click button function which loads the data from openweathermap API and displays it on a button click.
I tried to use getJSON and getJSONP for the same but the data is not getting displayed.
Here is my JS code:

function clicck(){
var url="";
// document.getElementById("demo").innerHTML=url;

My HTML code for the button is :

<p id="demo"></p>
<button onclick="clicck()">kuyku

I know its a basic question but I am really stuck on it.Your help would be appreciated.

Answer Source

I tried your solution, and find problem with JSONP function. If provided solution with misspelled selector $('#demo') does not works, here the fiddle using only jQuery ajax functions.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download