3
What am I doing wrong?
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
$('#btn1').click(function(){
var tmp = {"Proc":3236470};
$.ajax({
type: 'POST',
url: 'test.php',
data: {'rel':tmp},
success: function(data) {
$('body').append(data);
//alert(data);
}
});
});
});
</script>
</head>
<body>
<button id="btn1">
teste
</button>
</body>
test php.
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Content-Type: application/json; charset=utf-8')
$aDados = json_decode($_POST['rel'], true);
echo $aDados["Proc"];
?>
ERROR: Parse error: syntax error, Unexpected '$aDados' (T_VARIABLE)
If you can explain better the problem you have in particular and, if possible, show code you have done where this problem is. Your question is too broad, see Help Center How to Ask.
– Jorge B.
my question is simple, receive this $_POST in the report.php
– Jhonatan
Ajax is a request literally equal to the request a form makes to your php file, you work the
$_POST
in the same way that would work with a form. The Success in ajax represents success when making the request, it means q has not expired the request time, that the requested page exists and etc.– Erlon Charles
Okay, I get it, I use $.ajax with constantly. net mvc4, however, in php I’m having difficulties, I did everything I informed and q passed me here, but nothing works..
– Jhonatan
Display an error message on the Chrome console or firebug (firefox) ?
– rray
That last mistake,
unexpected '$aDados' (T_VARIABLE)
happened because a;
in the secondheader(....)
.– rray