Skip to content

Commit

Permalink
08.- Ajax con Jquery🌇 de 0 a 100 [ Ajax con php ]
Browse files Browse the repository at this point in the history
  • Loading branch information
programadornovato committed Jul 21, 2019
1 parent cfbcb83 commit c4f924d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
<body>

<div class="container mt-3">
<button type="button" class="btn btn-primary" id="ajax" >Ajax</button>

<button type="button" class="btn btn-primary" id="convertir" >Convertir</button>
<div class="form-group">
<input type="text" class="form-control" id="opracion" placeholder="opracion" value="may" >
<input type="text" class="form-control" id="texto" placeholder="texto">
</div>
<div class="alert alert-primary" role="alert">
<strong id="datosEmpleado">Datos empleado</strong>
<ul id="listaEmpleados">
Expand Down
27 changes: 8 additions & 19 deletions javascript.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
$(document).ready(function () {
$('#ajax').click(function (e) {
$('#convertir').click(function (e) {
e.preventDefault();
$('#listaEmpleados').html('');
$.ajax({
url:'empleados.json',
type:'get',
dataType:'json',
success:function(data){
console.log(data);
$.each(data.empleados, function (i, item) {
$('#listaEmpleados').html($('#listaEmpleados').html()+`
<li> ${item.nombre} </li>
`);
});
},
error:function(xhr,status,error){
console.log(xhr);
console.log(status);
console.log(error);
}
let opracion=$('#opracion').val();
let texto=$('#texto').val();
$.get("http://localhost/ajax/convertir.php",
{'operacion':opracion,'texto':texto},
function(data){
console.log(data);
$('#listaEmpleados').html(data);
});
});
});

0 comments on commit c4f924d

Please sign in to comment.