I have two scripts that are parsing data. The message.php works fine but when I am trying to send data to data.php I am facing the error:
"Notice: Undefined index: userid in D:\xampp\htdocs\metro\data.php on line 11"
The code:
<script type="text/javascript">
function post(){
var name = document.getElementById("name").value;
if(name==''){
swal('Type Your Message','You Cannot Send An Empty Message','error');
return false;
}
else{
$.ajax
({
type: 'post',
url: 'message.php',
data:
{
message:name,
userid: <?php echo $get; ?>
},
success: function (response)
{
alert(user);
}
});
return false;
}
}
</script>
<script type="text/javascript">
$(document).ready(function(){
setInterval(function(){
$('#show').load('data.php');
},1000);
});
</script>
<script type="text/javascript">
$(document).ready(function(){
var k =<?php echo $get; ?>;
if(k!=''){
$.ajax
({
type: 'post',
url: 'data.php',
data:
{
"userid": <?php echo $get; ?>
},
success: function (response)
{
alert(k);
}
});
return false;
}
});
</script>
The error is thrown:
Notice: Undefined index: userid in D:\xampp\htdocs\metro\data.php on line 11