Search code examples
formsjqueryfragment-identifier

jquery form plugin with hash change


currently im having problems with the jquery form plugin. Part of this because i need to change the hash value on form submit. Heres the basic of what im doing:

$(document).ready(function()  {
$('#search').ajaxForm({
target: '#pageContent',

success: function()  {
$('#pageContent'); //this is all i need to 'ajaxify' this form
var hash = 'query='+encodeURI(document.getElementById('query').value);
window.location.hash = hash;
}
});
});

Now what happens is i am able to change the hash value but my form no longer 'ajaxify's itself and instead i just get a blank page..

What am i doing wrong?


Solution

  • since no-one had a suitable answer i managed to hack my implementation of jquery.history.js to allow searching via ajax.. heres the code:

    $(document).ready(function() { 
    // bind form using ajaxForm 
    $('#search1').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#pageContent', 
    
        // success identifies the function to invoke when the server response 
        success: function() { 
            $('#pageContent'); 
            var hash = '#search.php?term='+($('#query').val()+'&submit=Submit').replace(/ /g, '+');
            update(window.location.hash = hash);
        } 
    
    }); 
    

    });

    i also replaced the spaces in the search to include + signs.. maybe this will help someone.