aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to solve back button problem in Ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to solve back button problem in Ajax" Watch "How to solve back button problem in Ajax" New topic
Author

How to solve back button problem in Ajax

Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
hiii i am using ajax to populate vehicle models from the selection of vehiclemake in the dropdown.When i submit the page and hit back it doesn't list the vehiclemodels for the make ...Anyway this is back button problem in Ajax ..What's solution for this??


SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Since the quintessential Ajax application has a single page, there general isn't a "back button problem". If the user hits the back button, he gets sent back to the previous site. The Refresh button, on the other hand, is a different matter...

Could you explain how your app is set up such that the back button does not bring them to the previous site? That would give us some insight into possible solutions.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Or....

Are you using a hidden iframe for the back-end calls or the XMLHttpRequest object? (When I hear the term "Ajax" used today, I assume usage of the XMLHttpRequest object.)

The iframes mechanism can have back-button issues of course since you are submitting requests into the iframe.
[ October 17, 2005: Message edited by: Bear Bibeault ]
Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
hiii i am using ajax to populate vehicle models from the selection of vehiclemake in the dropdown.When i submit the page and hit back it doesn't list the vehiclemodels for the make ...Anyway this is back button problem in Ajax ..What's solution for this?? This was my question in the forum

I am putting more focus on it..

I have one page search.jsp which has form elements that takes diferent search criteria.(Make,Model,year and other elements)

I am using ajax for populating Models on the selection of Make.so on the onchange event of Make i will try to populate dropdown of Model.I have Submit button also on the page.User hits submit and search listS the vehicles.Problem is when User try to go back and modify search They hit Back button of the browser.so it goes to search.jsp with the previous filled criteria by the user ..Here i don't have the Model list that waS populated from ajax from the Make.ihave Make though.Model Dropdown is empty.I am using Struts html tag library.so my all form fields are like
html:select html ptions html:form and other strust html tag library.In ajax i am calling a servlet which gets list of vehicle ids and send an xml via XMLHTTPRequest object

Thanks
Brad Neuberg
Greenhorn

Joined: Oct 29, 2005
Posts: 1
Hi folks. I just posted an article on the O'Reilly Network that addresses this exact problem; it might be useful to you:

AJAX: How to Handle Bookmarks and the Back Button

The article above also details how the refresh button issue can be solved.

I also cover these kinds of topics on my weblog regularly, including the different kinds of iframe behaviors, persisting data between browser sessions, and more at codinginparadise.org.
[ October 29, 2005: Message edited by: Brad Neuberg ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to solve back button problem in Ajax