I have this code which uses jquery and ajax to send a request to the other page i.e.
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<input type="button" id="butt" value="button11111111111111" >
</html>
<script>
$("#butt").on('click',function(e)
{
$.ajax(
{
type:'POST',
url:'testmysql.php',
data:
{
product_type:"cake";
}
});
});
</script>
When i click the above button it should send the request and data to the other file testmysql.php
<?php
session_start();
$_SESSION['type']=$_POST['product_type'];
echo $_SESSION['type'];
?>
However , when i refresh the other page after clicking the button i do not see any kind of echo and it gives me a notice stating
Undefined index: product_type
Since, i am new to ajax and jquery is there anything i am missing ?if yes,then what should i do to make this work ?
Thanks!
Note: Both of them are in the same directory.