This is my code:
<script>
$(document).ready(function() {
$('#status').on('submit',function(e) {
$.ajax({
url:'message.php',
data:$(this).serialize(),
type:'POST',
success:function(data){
console.log(data);
$("#success").show().fadeOut(5000); //=== Show Success Message==
$('#statusBox').val("");
var passid = <?php echo $passid;?>;
$("#loadViajquery").load(
"messages2.php",
{ id: passid }
);
},
error:function(data) {
$("#error").show().fadeOut(5000); //===Show Error Message====
}
});
e.preventDefault(); //=== To Avoid Page Refresh and Fire the Event "Click"===
});
});
</script>
And then the PHP code on messages2.php
if (isset($_GET['id'])) {
echo $_GET['id'];
}
This is not working, the problem is the variable (GET) is not being received. What could be the problem?
I tested removing the isset from the php script and just echoing static text and it worked, so the issue is definitely that the GET isn't being received, but I can't work out why.
This is the code that displays what is supposed to come from messages2.php
<script type="text/javascript">
$(document).ready(function() {
$("#loadViajquery").load("messages2.php");
});
</script>
<div id="loadViajquery">
</div>