-1
I did this ajax here, PS: the data reaches the.php data file.
$.ajax({
type: 'post',
data: $( this ).serialize(),
dataType: 'json',
url:'simulacao/dados.php',
success: function(data){
alert(data);
var objeto = data;
$('#resposta').append(data.total_direta);;
}
});
However, I cannot show the values on the screen... The result of json is this
{"total_direta":"21.450,00","total_indireta":"0,00","total_geral":"47.500,00"}
My doubt is, as I show it, there is a div called id="answer" but it gets nothing...
So I tried but did not show the result on the screen, so as I said it even goes the answer, calculates, everything... Shows
{"total_direta":"21.450,00","total_indireta":"0,00","total_geral":"47.500,00"}
but does not return and prints on screen... :/– Diego Ananias
So instead of making $('#answer'). append(), switch to $('#answer'). text();
– Seu Madruga
I edited my answer to make it clear.
– Seu Madruga
is, no, also not printed the json result on the screen...
– Diego Ananias
Dude, it would be nice if you put the whole code there then. It gives the Alert in the data, but doesn’t enter the #answer? Weird.
– Seu Madruga
Try taking the line from: dataType: 'json'
– Seu Madruga
So actually neither does the Alert it does, but the status of the answer is 200, so it should fall into the Success... But, I took out dataType: 'json', and still it wasn’t, nor the screen print... The.php Data Code here
– Diego Ananias
/*Comissao direta*/ 
 $porcentagem = '1.43%';
 $casas_vend = $_POST['casa_vend'];
 $media_valor = $_POST['media_valor'];
 $total_direta = (($media_valor * $porcentagem) / 100) * $casas_vend ; 
 $data = array('total_direta'=> $total_direta,'total_indireta' => $total_indireta, 'total_geral' =>$total_geral);
 
 
 echo json_encode( $data );
– Diego Ananias
The errors are in php. I made here and returned a number of errors, among them, the fact that you are making mention of the binary variables. And you were supposed to have edited the answer and put the code, not here in the comments. It got very confusing...
– Seu Madruga
is that I took what didn’t really matter... But all these variables exist and I created them in one place... I’m going to put in Pastebin..
– Diego Ananias
I got here, actually had 2 points... dataType that was missing, and had a method that did not exist called number_format in js, but I solved here the
– Diego Ananias