0
Guys, I have this ajax and a page called test.php that gets a value, I wonder if my ajax is right and this value is being picked correct inside the test.php page
<script>
$('input[name=valor]').click(function() {
var campoRadio = $('input[name=valor]:checked').val();
$.ajax({
method: "POST",
data: { campoRadio: campoRadio },
url: "test.php",
dataType: "php"
});
alert(campoRadio);
});
</script>
test php.
$valor = $_POST["campoRadio"];
Yeah, you’re doing it right, just put a
success: function(data){}
to have the return ofphp
and perform some action– Rafael Augusto
That one
dataType: "php"
that didn’t make much sense, only. With it you will inform jQuery what is the type of return expected in the answer. Usually it is text, html, json or xml.– Woss
I think with this code is not passing the value
campoRadio
for the pagetest.php
, What else does the pagetest.php
besides taking the value from the form? Perform some routine with the$valor
to load something into the ajax page? Or just want to pass the value totest.php
?– user60252
Leo, this test would be a pagseguro.php, and I send is the value of a plan inside it, but it’s not working, it seems to me that I get the value inside of pagseguro.php, but pagseguro can not run!!
– Marcos Pereira