Skip to content

Instantly share code, notes, and snippets.

@Uriel29
Last active March 31, 2016 12:55
Show Gist options
  • Save Uriel29/2d3dbb509db4c120e8072dd8bc2921e9 to your computer and use it in GitHub Desktop.
Save Uriel29/2d3dbb509db4c120e8072dd8bc2921e9 to your computer and use it in GitHub Desktop.
Forma simples de receber e manipular Json com Jquuery $.get e $.getJSON nesses 2 arquivos mostros 2 formas de fazer isso.
$(document).ready(function(){
$.get( "http://seu site/", function( data ) {
data = typeof data == 'string' ? JSON.parse(data) : data;
data.forEach(function(elementoDaArray) {
var div = document.createElement('div');
id = elementoDaArray.id;
cidade = elementoDaArray.cidade;
console.log(cidade);
console.log(id);
//div.innerHTML = JSON.stringify(elementoDaArray);
//document.body.appendChild(div);
});
$.getJSON( "http://seusite.com/", function( data ) {
//console.log(data);
console.log(data[0]['cidade']);
console.log(data[1]['cidade']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment