Last active
March 31, 2016 12:55
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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