php file loaded with jquery not displaying php variables
I have a PHP file that contains a button. When the button is clicked an external PHP file is loaded into a div on the same page. The external PHP file contains a form with a hidden variable, the values is set to a PHP variable that was defined in the page with button.
S开发者_StackOverflowince the PHP file is loaded into the page's div shouldn't it have the same variables as the page?
HTTP is stateless. There's no inherent connection between one request and another, even if they were both requested at the same time. The variables used in a page normally get tossed out when the request is done, and simply aren't there for the next request.
If you want to carry a variable over from one PHP script to another, you'll need to either put it in $_SESSION, use cookies, or pass the variable in the query string when you request the contents for your div.
精彩评论