开发者

php header redirect not working

I'm using an ajax call to trigger a php redirect using headers. According to chrome's developer tools the content of the page is loaded (ie: is in the resource list), but the page never redirects.

I'm not getting any error codes. Here's the php:

<?php  
ini_set('display_errors', false);  
if (!isset($_SESSION)) {  
  if($_POST['email']){  
    ...several calls to external db...  
    if(strlen($response->supporter->item->Email))
      //user is a member
      header('Location: http://www.example.com/page-one/');
    else
      header('Location: http://another-site.com/');
  }
}
?>

Nearly exactly the same code works in another part of the site. Any ideas why this is pulling the correc开发者_C百科t content, but not loading it on the page?

the ajax call is:

$.post("http://www.our_site.org/is_member.php", { email: email });


Try That:

<?php  
ini_set('display_errors', false);  
if (!isset($_SESSION)) {  
  if($_POST['email']){  
    ...several calls to external db...  
    if(strlen($response->supporter->item->Email))
      //user is a member
      echo ('Location: http://www.example.com/page-one/');
    else
      echo ('Location: http://another-site.com/');
  }
}

?>

And inside of your js do that:

$.ajax({
  type: 'POST',
  url: "http://www.our_site.org/is_member.php",
  data: {email: email },
  success: function(output){ window.location = output; }
  dataType: dataType
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜