Kinderly Wade
asked on
refresh page after AJAX POST redirect back to the previous page
Dear experts!
I am experiencing this weird situation as for the first time. I am currently using PHP, html, and JQUERY to design my pages.
I have navbar that direct user to 3 distinctive pages:
1. Home Page
2. inventory
3. Sales
Home page is set as the default page. If select the Inventory option in navbar it will bring me to hte inventory page and same concept applies to sales page.
I am using ajax POST which will pass some values over to the either the inventory or the sales. I was able to navigate from home to inventory or inventory to sales or sales to inventory etc.... without any issue.
But somehow when I hit the F5 or the refresh option in my browser (I am using Chrome and Firefox) it will redirect me back to Home page.
I am wondering why it does that? Doesn't it suppose to stay on the inventory page if I am currently on inventory page?
I tried to trouble shoot here is the strange thing. If I am on Home page and POST to inventory page, I can see my variable that I want to post over to the inventory page ( with the from the $_POST variable and the $_POST variable has a value that tells me what page I am on). If I hit the refresh button or F5, I can see the $_POST value that redirect me to home page instead of the inventory. This kind of trouble me as to why I get redirected back to home instead of staying on the inventory page.
I am experiencing this weird situation as for the first time. I am currently using PHP, html, and JQUERY to design my pages.
I have navbar that direct user to 3 distinctive pages:
1. Home Page
2. inventory
3. Sales
Home page is set as the default page. If select the Inventory option in navbar it will bring me to hte inventory page and same concept applies to sales page.
I am using ajax POST which will pass some values over to the either the inventory or the sales. I was able to navigate from home to inventory or inventory to sales or sales to inventory etc.... without any issue.
But somehow when I hit the F5 or the refresh option in my browser (I am using Chrome and Firefox) it will redirect me back to Home page.
I am wondering why it does that? Doesn't it suppose to stay on the inventory page if I am currently on inventory page?
I tried to trouble shoot here is the strange thing. If I am on Home page and POST to inventory page, I can see my variable that I want to post over to the inventory page ( with the from the $_POST variable and the $_POST variable has a value that tells me what page I am on). If I hit the refresh button or F5, I can see the $_POST value that redirect me to home page instead of the inventory. This kind of trouble me as to why I get redirected back to home instead of staying on the inventory page.
ASKER
Hi Chris!
Thanks for the reply. Sorry. Maybe I wasn't clear on my explanation. I have a <div> tag. If I click on the Home page the content of that <div> tag will swap over to the home page content. If I click on the Inventory on navbar then that div tag will show the content in the <div> tag. Sorry that I used to say to a different page as in usual form post will redirect me to a different page. So what happened was that I can see the correct content in the <div> tag according to the selection in the nav bar that I pressed. Weird thing is that when I hit F5 or refresh button on the browser, it will always go back to the home page content in <div> tag. I thought the <div> content stays with the current selection let's say the inventory content but for some reason when I hit refresh the information that I am gett'n is the home page instead of the inventory. Very strange.
Thanks for the reply. Sorry. Maybe I wasn't clear on my explanation. I have a <div> tag. If I click on the Home page the content of that <div> tag will swap over to the home page content. If I click on the Inventory on navbar then that div tag will show the content in the <div> tag. Sorry that I used to say to a different page as in usual form post will redirect me to a different page. So what happened was that I can see the correct content in the <div> tag according to the selection in the nav bar that I pressed. Weird thing is that when I hit F5 or refresh button on the browser, it will always go back to the home page content in <div> tag. I thought the <div> content stays with the current selection let's say the inventory content but for some reason when I hit refresh the information that I am gett'n is the home page instead of the inventory. Very strange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the late reply. Thanks guys! Problem solved!
Maybe explain what you're tying to do and we can help out