3
To get the content of a page I use the date, but I would like to know how to get only one variable on another page. I use this code:
jQuery(document).ready(function(){
jQuery('.teste').submit( function(){
var teste = $(this);
var dados = teste.serialize();
jQuery.ajax({
url: "teste.php",
type: "POST",
data: dados,
success: function(data)
{
teste.html(data);
}
});
return false;
});
});
But it takes all the content from the page. How would I get only one PHP variable, for example: "$test". I put an example below to illustrate better, I know it is not that way.
jQuery(document).ready(function(){
jQuery('.teste').submit( function(){
var teste = $(this);
var dados = teste.serialize();
jQuery.ajax({
url: "teste.php",
type: "POST",
data: dados,
success: function(data)
{
teste.html(data.$teste);
}
});
return false;
});
});
Test page.php
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
$teste ="teste";
$teste2 ="teste2";
echo $teste;
echo $teste2;
?>
</body>
</html>
What is the format of the return?
– Don't Panic
You can ask the question the file code
teste.php
?– Woss
Post the code of the test.php
– Darlei Fernando Zillmer
Sending via get url does not work?
– Julio Henrique
If you work with feedback on
json
you can map what you want to display– Rafael Augusto
So it only works with JSON?
– Luizinho
In a certain way yes, besides being the most indica form. But you can use
web crawler
to do this too– Rafael Augusto