Reputation: 361
I have two pages one for filling data and other one for initializing data I am sending the filled data via post method using ajax, I want to redirect the user from initializing page, i used simple header("Location: somelocation");
in the initialize page but it seems it does not work this way and it just sends the html value of the target page using ajax (I checked it with firebug),so what is the alternatives here ? should i use ajax it self for the redirection part?
Upvotes: 0
Views: 1523
Reputation: 106
You should return your location via json response, for example {"location": "somelocation"}, and then handle it in ajax success callback and go to page you need:
document.location.href = somelocation
Upvotes: 1
Reputation: 165
You should use javascript for the redirection, not ajax.
When your ajax request has completed successfully you should then do a window.location = 'new/path/to/some/location';
Using the header("Location: ...") in your destination PHP script (the one that receives the data) will only return to you the html in the ajax response body, but not interpret it.
Upvotes: 0