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
//hoje veremos mais um pouco sobre callbacks | |
//Se pararmos para analisar, esse recurso que vínhamos | |
//usando: window.onload = function... é na verdade um callback | |
//SIM! na verdade estamos passando uma função para ser executada | |
//quando os elementos já tiverem sido renderizados na janela | |
window.onload = function () { | |
//Estamos criando um callback personalizado | |
var meuCallback = function (event) { |
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
<!DOCTYPE html> | |
<html lang="pt" dir="ltr" class="client-nojs"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<script type="text/javascript" src="arguments.js"></script> | |
</head> | |
<body> | |
<div id="wrapper"></div> | |
</body> | |
</html> |
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
<!DOCTYPE html> | |
<html lang="pt" dir="ltr" class="client-nojs"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<script type="text/javascript" src="ajax-sem-jquery.js"></script> | |
</head> | |
<body> | |
<div id="wrapper"> | |
<button id="button-ajax">Fazer nova solitação Ajax</button> | |
</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
//Aqui declaramos todas as variáveis que serão usadas | |
var requisicao = null, | |
serverResponse = null, | |
parsedData = null; | |
//esse callback (SIM, olha ele aí de novo) será chamado | |
//quando o evento 'onreadystatechange' for disparado | |
var meuCallback = function (data) { | |
//um parâmetro 'data' é passado para o callback quando este é chamado |
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
<?php | |
//Aqui no Backend criamos uma variável 'data' | |
$data = array(); | |
//o primeiro índice recebe um objeto com 'nome' e 'amo de nascimento' | |
$data[0] = array('nome'=> 'Isaac Newton', 'ano de nascimento'=>1727); | |
$data[1] = array('nome'=> 'Nikola Tesla', 'idade'=>1856); | |
//o parametro 'numeroAleatorio' receberá um número aleatório gerado |
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<title>CSS Challenge 1</title> | |
</head> | |
<body> | |
<h1>Shakespeare's Sonnet #18</h1> | |
<p> | |
This is one of the most famous of the sonnets. It is referenced |
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
<!DOCTYPE html> | |
<html lang="pt" dir="ltr" class="client-nojs"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<script type="text/javascript" src="jquery-1.9.0.js"></script> | |
<script type="text/javascript" src="ajax-com-jquery.js"></script> | |
</head> | |
<body> | |
<div id="wrapper"> |
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
//Já usamos window.onload várias vezes, talvez agora possamos usar | |
//um recurso de jQuery para cumprir uma função parecida | |
//farei um post explicando a diferença entre window.onload | |
//e $(document).ready | |
$(document).ready(function () { | |
//estamos usando um dos grandes facilitadores do framework | |
//a capacidade de selecionar elementos com seletores css | |
//aqui seria a mesma coisa do que fazer document.getElementById... | |
//No entanto, o retorno da chamada $('#button-ajax') é um 'objeto jQuery' |
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
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<script type="text/javascript" src="gradient-change.js"></script> | |
</head> | |
<body> | |
<div id="wrapper"></div> | |
</body> | |
</html> |
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
//Nosso clássico callback | |
window.onload = function () { | |
//A div 'wrapper' | |
var div = document.getElementById('wrapper'); | |
//o 'onclick' recebe um callback |