Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to solve back button problem in Ajax

 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic