jquery ajax using 'addresses' to update url for bookmarking

Posted by Jay on Stack Overflow See other posts from Stack Overflow or by Jay
Published on 2010-03-30T01:23:54Z Indexed on 2010/03/30 1:33 UTC
Read the original article Hit count: 702

Filed under:
|
|
$("document").ready(function(){
    contM = $('#main-content');
    contS = $('#second-content');
    $(contM).hide();
    $(contS).hide();
    function loadURL(url) {
        console.log("loadURL: " + url);
        $.post(url,{post_loader: 1},{post_loader: 1}, function(data){
                                                               $(contM).html($(data));
                                                               $(contM).show();
                                                               });
    }


    // Event handlers
    $.address.init(function(event) {
        console.log("init: " + $('[rel=address:' + event.value + ']').attr('href'));
    }).change(function(event) {
        $.post($('[rel=address:' + event.value + ']').attr('href'), {post_loader: 1}, function(data){
                                                                                               $(contM).html($(data));
                                                                                               $(contM).show();
                                                                                               });
        console.log("change");
    })

    $('.update-main a').click(function(){
        loadURL($(this).attr('href'));
    });
});

I'm using this code to make calls to a server to update the main content of a web page. Everything works fine in Google Chrome, but fails to execute properly in Firefox.

The strange thing is that when I have the console open to monitor server communication, the application works fine, only when it is closed do problems occur : the script starts to communicate with the server, but before it receives the data the browser jumps to the source url.

any ideas?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about addresses