0
I have the following script, which processes the form and updates the div #list by ajax:
<script type="text/javascript">
$(document).ready(function(){
$("#formulario").on("submit", function(e){
e.preventDefault();
var cdb = $("#cdb").val();
$.ajax({
url: "confere.php",
method: "POST",
dataType: "html",
data: {cdb: cdb}
}).done(function(data){
$("#cdb").val("");
$("#cdb").focus();
listar();
}).fail(function(data){
alert("Erro");
});
});
});
function listar() {
$.ajax({
url:"lista.php",
success: function (textStatus) {
$('#lista').html(textStatus);
}
});
}
</script>
What I would like to treat is the return of confere.php
, and not only validate with the .done
and .fail
.
For example:
The return of confere.php
may be "X", "Y", "Z", and upon return, perform an action.
Filing cabinet: confere.php
<?php
$cdb = filter_input(INPUT_POST,'cdb');
$valor = $cdb/10;
gravar($valor);
function gravar($texto){
$arquivo = "temp.txt";
$fp = fopen($arquivo, "a+");
fwrite($fp, $texto . ";");
fclose($fp);
}
?>
You know what the parameter is
data
that you used on.done
?– Woss
No puts, and I hadn’t noticed. I know almost nothing about JQUERY. If you have any good articles about these requests, I really appreciate it !
– rbz