This is my html with script
<div id="info" class="container-fluid">Here is some text</div>
<script src="js/jquery-2.1.4.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
$.post("testPHP.php", {name: "John"}, function(data)
{
$( "#info" ).html( data )
})
</script>
and the php code
<?php
$name=$_POST['name'];
echo $name;
?>
In html I may see the name John displayed in the div with id info. But when I run the php file I get this error
Notice: Undefined index: name in C:\xampp\htdocs\ticketing\testPHP.php on line 2
How can I send a variable via Ajax to a php file and echo this?
$.post().name) with AJAX to a PHP file.. What are you trying to do?