tags:

views:

127

answers:

2

Hi guys! What can I do if I want the browser to "remember" search results requested with ajax? I am using the jquery plugin Jquery Address but I can't piece together how to do it

here's a code snippet from my form submission:

var ajaxforms = {
    searchoptions : function(){
        $('form#searchoptions').ajaxForm({
            url : base_url + 'search/categorysearch',
            target : '#search_result',
            beforeSubmit : blocksearchdiv,
            success : revise_searchtable_onsuccess
        });
    },
    searchfilters : function(){
        $('form#searchfilters').ajaxForm({
            url : base_url + 'search/filter',
            target : '#search_result',
            beforeSubmit : blocksearchdiv,
            success : revise_searchtable_onsuccess
        });
    },
    searchterm : function(){
        $('form#termsearch').ajaxForm({
            url: base_url + 'search/termsearch',
            target : '#search_result',
            beforeSubmit : blocksearchdiv,
            success : revise_searchtable_onsuccess
        });
    }

and here's the callback function revise_searchtable_onsuccess:

function revise_searchtable_onsuccess()
{
    $(function(){
        $.tablesorter.defaults.sortList = [[0,1]];
        $('#tableresults').tablesorter();
    });
    $.address // don't know what comes next
    unblocksearchdiv();
}

please help me implement jquery address with this; or maybe you have implemented this with other plugins?

+1  A: 

The documentation for jQuery Address is available at jQuery Address - Docs. You are probably interested in using $('a').address(), which is used to change the URL used in <a>.

kiamlaluno
A: 

Im not positive this is what you want, but heres how I get results from a hash when a page (url) is loaded with a hash.

Note, This is JS not JQ, but from here JQ it up all ya want.

You will have to re-think your hash structure. Make it easily parse-able with .split() for multiple values.

Check for hash

if(window.location.hash) {
    var hash =window.location.hash.substring(1);// ignores #
}

From there, parse the hash variable to get the information, then query the database to get the same results as before.

so somepage.php#search=string_term=blah can be broken into vars on load, then be made into a query

Douglas