php - POST data to redirect page fail -


i totally confused following situation...

situation

post data a.php b.php , redirect b.php...but fail

code - a.php

<html>   <head>     <script src="http://code.jquery.com/jquery-1.9.1.js"></script>     <script>       $(document).ready(function() {         $('#submit').click(function() {           $.ajax({             url: 'b.php',                 datatype: 'html',             type: 'post',             data: {                value: $('#value').val()             },             error: function(xhr) {               console.log('ajax went wrong!');             },             success: function(response) {               console.log(response);               window.location.href = "b.php";                   }           });          });       });     </script>   </head>   <body>     value: <input type="text" id="value">   </body> </html> 

code - b.php

<?php   echo $_request['value']; ?> 

a.php can right response b.php without redirect function. however, once include statement window.location.href = "b.php";, a.php redirect b.php without printing anything. why situation happening? there solution fix this?

thanks!

you can't pass data between pages in way. posting data b.php , redirecting - 2 different requests.

if want pass data via redirecting - use params:

window.location.href = "b.php?value="+$('#value').val(); 

also form submission directly b.php can you.

<form action="b.php" method="post">     <input name="value" />     <input type="submit" /> </form> 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -