Im new to jqeury ajax and i try to post something testso.php
. I try to echo $_POST['test']
this on testso.php and its not showing anything. If i open my developer tools and check on preview i can see data is there. am i doing something wrong.
test.php
<script>
var test = '123';
$.ajax({
type: "POST",
url: "testso.php",
data: { test: test },
success: function(response) {
console.log(response);
}
});
</script>
testso.php
<?php
if(isset($_POST['test'])){
$img = $_POST['test'];
?>
<div><?php echo $img; ?></div>
<?php } ?>
i try to use document.getElementById('ajaxreturn').innerHTML=test;
but this is not what i want. Maybe someone can suggest me how to echo the post.