Reputation: 955
At my page when a user click any book name from list, it will be send data a php query and after query that book page will be open at browser.
Now after php process it cannot redirect any book page. I tryed also redirect with echo("<script>location.href = 'http://myweb.com/$user';</script>");
and ob_start();
at top, But not work also. There is no blank space before & after php and have no error log also. Chrome network tools display sent data well to testpage.php and also open that book's page there. But browser dose not redirect at any page.
This is page button:
<a href="javascript: void(0)" id="'.$mypage.'" class="user"> '.$mypage.'</a>
JS script:
$(document).on('click', 'a.user', function(e){
var getID = $(this).attr('id');
$.post("../testpage.php?user=" + getID, function(){
});
});
Testpage.php
<?php
error_reporting(E_ALL);
require('db.php');
if($_REQUEST['user'])
{
global $db;
$user=$_REQUEST['user'];
//others all process
header("location: http://myweb.com/$user");
exit;
}
?>
Upvotes: 1
Views: 48
Reputation: 40909
testpage.php is called by your AJAX request and that's the request that will get redirected. In order to redirect the main page (the one that is sending the AJAX request), you'll need to do the redirect in javascript in the callback called after successful AJAX call:
$(document).on('click', 'a.user', function(e){
var getID = $(this).attr('id');
$.post("../testpage.php?user=" + getID, function(){
window.location = 'http://myweb.com/' + getID;
});
});
Upvotes: 3