Bernardao
Bernardao

Reputation: 500

Redirect and reload

I am using this javascript code for a redirection:

window.location.href = '/zona-privada?message='+data;

I am working with php as a backend, after the redirect, my php it is not getting the message parameter. But if I reload the page after it has been redirected it works fine. Should I do the redirect in a different way? Or what I am doing wrong?

This redirection I am doing it in the javascript of an ajax request. Thank you very much

Ajax code:

$.post(
  "/url"
).done(
  function(data){
    window.location.href = '/home?message='+data;
  }
);

my php (using Zend1)

if($this->_params['message']) {
   //code goes here
}

Upvotes: 0

Views: 234

Answers (1)

Silz
Silz

Reputation: 256

The problem is with the value of your variable .Try encodeURIComponent(data) before appending it to the window.location.href

Upvotes: 1

Related Questions