0

I'm actually creating a form and I use Ajax to sort the $_POST.

$.ajax({type:"POST", data: $(formLogin).serialize(), url:"php/script/script-form.php",
   success: function(e){
   
   }
  });

In the php file "script-form.php", I need to do a header location. I write in this php file : header('Location: photos.php) but it doesn't work ...

In google Chrome, in the network tab, I can see that the php file photos.php is running correctly. But I dont't see the header location in my browser in the address .

What's wrong in my script please ?

Thanks a lot !

1 Answers1

1

Script-form.php is not sending data to the browser in this case, it's running on the server and returning results to your Javascript, therefore header() will not work.

You will need to use a Javascript redirect.

$.ajax({type:"POST", data: $(formLogin).serialize(), url:"php/script/script-form.php",
            success: function(e){
               window.location = "http://www.yoururl.com";
            }
        });