Last active
October 4, 2015 17:08
-
-
Save danilodorgam/90119d2c82a425bd96bb to your computer and use it in GitHub Desktop.
teste com html + php + ajax
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
$('#seila').submit(function(e){ | |
e.preventDefault(); | |
if($('#enviar').val()=='Enviando..'){ | |
return (false); | |
} | |
//em vez de mudar o valor do butão poderia mudar inserir o circulo rodando | |
$('#enviar').val('Enviando..'); | |
$.ajax({ | |
url: 'processa.php', | |
type: 'POST', | |
dataType: 'html', | |
data:{ | |
'metodo':$('#metodo').val(), | |
'salario':$('#salario').val(), | |
'tempo':$('#tempo').val(), | |
} | |
}).done(function (data){ | |
alert(data); | |
$('#enviar').val('enviar'); | |
$('#salario').val(''), | |
$('#tempo').val(''), | |
}); | |
}); |
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> | |
<head> | |
<!--Import Google Icon Font--> | |
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | |
<!--Import materialize.css--> | |
<link type="text/css" rel="stylesheet" href="<?php echo URL_TEMA?>css/materialize.min.css" media="screen,projection"/> | |
<!--Let browser know website is optimized for mobile--> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | |
</head> | |
<body class="light-blue darken-4"> |
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 | |
include("header.php"); | |
?> | |
<form class="row" id="seila" > | |
<input id="metodo" type="hidden" class="validate" name="id" value="0"> | |
<div class="col s12"> | |
<div class="input-field col s12"> | |
<i class="material-icons prefix">work</i> | |
<input id="salario" type="number" class="validate" name="salario"> | |
<label for="icon_prefix">valor</label> | |
</div> | |
</div> | |
<div class="input-field col s12"> | |
<i class="material-icons prefix">query_builder</i> | |
<input id="tempo" type="number" class="validate" name="tempo"> | |
<label for="icon_telephone">Tempo Trabalhado</label> | |
</div> | |
</div> | |
<input type="submit" id="enviar" placeholder="Enviar"> | |
</form> | |
<div id="result"></div> | |
<script type="text/javascript" src="<?php echo URL_TEMA?>js/validacao.js"></script> | |
<?php include("footer.php") ?> |
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 | |
if(strcasecmp('seila', $_POST['metodo'])==0){ | |
$html = 'Tempo: '.$_POST['tempo']; | |
$html .= "<br>"; | |
$html .= 'Salario: '.$_POST['salario']; | |
echo $html; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment