I have a file that, when called, should redirect to another location. In order to make sure that nothing is sent before the header, I call a file whose only content is the header. I also tried to redirect with other methods, but nothing seems to work. Here is the code:
first there is an ajax call that (successfully) sends some data to file1.php
$.ajax({
url: "file1.php",
type: "POST",
data: {id:10},
success: function(){
},
error: function (){
}
});
the file1.php gets the data and calls bridge.php
<?
if (isset($_POST['id'])) {
$selected_id = $_POST['id'];
}
require('./code/bridge.php');
?>
the file bridge.php should redirect to the new url. I tried the following (not simultaneously) 1.
<script>location.href='https://www.google.al/?gws_rd=cr,ssl&ei=l82QVqyAHIb6O5bJs6gK'</script>
2.
<?
echo '<META HTTP-EQUIV="Refresh" Content="0; URL= https://www.google.al/?gws_rd=cr,ssl&ei=l82QVqyAHIb6O5bJs6gK">';
?>
3.
<?
header("location: /edit_document");
?>
4.
<?
ob_start();
header("location: /edit_document");
?>
I am using firebug to see the response. It gives a status 200 (request was fulfilled). POST gives the right parameter that I sent. Response gives the page where I am trying to redirect. But redirect won't happen.
I reduced the code to this point to eliminate all things that might cause problems. I know you might be wondering why would I write a code that seems to do nothing. But if it doesn't work like this, I doubt I could catch the problem with lots of other calls. Also, I intended to use header for redirecting, but tried other options out of desperation.