user982853
user982853

Reputation: 2488

Jquery Hash Change - Ajax Form Back Button

I am using the Jquery Hash Change to manage my back button.

Link: Jquery Hash Change

It works fine with a link ('a') is click, it adds the href as the hash. Links work fine.

My question now is how do i get this to happen when my form button is clicked. I have form buttons that when clicked triggers an ajax call that processes my form and loads the success page (all without leaving the current page). When the submit button is clicked to process the form, it does not create a hash so even though the form was processed, when the back button is click it jumps to the previous page instead of back to my form.

How do i add this functionality so that when forms are submitted via ajax i can get back to the form using the back button? Thanks.

Upvotes: 1

Views: 1718

Answers (1)

charlietfl
charlietfl

Reputation: 171669

use the window.location object

set hash

location.hash='foooo';

get hash

var hash = location.hash

Set hash in success of form submit ajax

Upvotes: 1

Related Questions