When i try to ajax post, the second page containing header which causes the page to get status code '0'.
Now, i have to load google page in index in some section or any div. Our target is to get the header loaded file too.
index page:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p class="result">Click me too!</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$.ajax({
type: 'POST',
url: 'sub2.php',
cache: false,
dataType: "html",
success: function(data){
alert(data);
$(".result").load("sub2.php");
},
error: function(jqXHR, textStatus, errorThrown) {
alert("status:"+jqXHR.status);
alert("text:"+textStatus);
alert("thrown:"+errorThrown);
$(".result").load("sub2.php");
},
});
</script>
</body>
</html>
sub2.php page;
<?php
echo "hello";
header("location:https://google.com");
?>