Get Ajax Previous Request with Brower Back Button

I’m facing a situation with Ajax request on back button.

I created a form which posts values and returns results via ajax request according the given filters and loads on a specific div. When I click on any of the link on page, it opens the new url as expected. On clicking on browser back button it opens the previous form page with default values. How can I enable browser state functionality so that I have results with last posted values with browser back button. Note that type of ajax is POST.

One solution I got is that to modify this form type to GET instead of POST, but this would take much time to do changes in server side code.

var page_url = $(this).attr('href');
page_url = page_url.split(':');
var page = page_url['1'];

$form = $('#form);

        $.ajax({
        type: 'POST',
        data: $form.serialize(),
        url: webroot + 'controller /action/page:'+page
        }).done(function (result){
})

I want to know the possible solution. Thanks in advance.

Answers


you can use Jquery .unload() function or try cookies you could read it from here How to set/unset cookie with jQuery?


Once you submitting that time dont go for new page, just hide the form elements and display new content in other div. Once you click on back button just show previously hidden div and hide current showing div


Need Your Help

Understanding variable scope in Python classes

python class variables scope

Can someone please explain why this will fail:

Why embed lua into a game engine?

scripting lua embed

I've been looking into building a basic game engine from the ground up and after making a list of features that are common to other engines, one of the bigger things is the fact that they have an

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.