---
title: "Scurt tutorial Jquery GetJson"
description: "Hai sa incarcam niste date in format JSON (JavaScript Object Notation) de pe un server extern folosind un request de tip GET. Pentru asta ne vom folosi de functia getJson() din jQuery. Aceatsa..."
url: https://blogdeit.ro/scurt-tutorial-jquery-getjson
date: 2018-03-08
modified: 2018-03-08
author: "Radu Popescu"
image: https://blogdeit.ro/wp-content/uploads/2021/07/vdi-coding.jpg
categories: ["Coding", "RO", "Tutorial"]
tags: ["ajax", "api", "getjson", "jquery", "js", "json", "tutorial"]
type: post
lang: en
---

# Scurt tutorial Jquery GetJson

Hai sa incarcam niste date in format JSON (JavaScript Object Notation) de pe un server extern folosind un request de tip GET. Pentru asta ne vom folosi de functia **getJson()** din jQuery. Aceatsa functie foloseste AJAX (Asynchronous JavaScript and XML), un mod prin care serverul trimite doar datele de care ai nevoie intr-o pagina fara sa o incarce pe toata.

**Codul folosit in video**

$(function() {
$('.button').click(function(){
$.getJSON( 'https://api.fixer.io/latest?base=Ron', function( json ) {
console.log(json.date);
console.log(json.rates.EUR);
$('.a').append(json.rates.EUR);
});
});
});

**Alte surse JSON online**

- (https://openweathermap.org/current)

- (https://www.instagram.com/popescuradhoo/?__a=1)

- (http://worldcup.sfg.io/matcheshttps://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=Apple)

- (http://api.open-notify.org/iss-now.json)

- (https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json)

**Exemplu cu live data (positia Statiei Spatiale Internationale)**

function getISS(){
$.getJSON( 'http://api.open-notify.org/iss-now.json', function( json ) {
$('#issLat').text('Latitudine: ' + json.iss_position.latitude);
$('#issLon').text('Longitudine: ' + json.iss_position.longitude);
});
}
$(function() { setInterval(getISS, 1000); });
