Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to solve back button problem in Ajax

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic