To get the contents 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 of the page. How would I get only one PHP variable, for example: "$ test". I've put an example below to better illustrate, I know it's 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.php page
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
$teste ="teste";
$teste2 ="teste2";
echo $teste;
echo $teste2;
?>
</body>
</html>