Skip to content Skip to sidebar Skip to footer

Jquery, Shadowbox And Ajax

I would like to load some content using AJAX and Shadowbox Basically I would like the user to goto a page in case javascript is off. So this is what I want to do :- 1) Cancel the c

Solution 1:

Since you're not getting any JavaScript errors try debugging by breaking it down:

Ensure that the binding to and overriding of the click event is functioning properly:

$('h2 a').bind('click', function() {
    alert('click even fired');
    returnfalse;
});

If that works, check the data that your ajax request is returning:

$('h2 a').bind('click', function() {
    var id = $(this).attr('id');
    $.ajax({ 
        url: "ajax-post.php?p="+id, 
        success: function(data){
           alert(data);
        }
     });
    returnfalse;
});

The code looks like it should work, so I'm guessing there's either something wrong elsewhere (in which case the first test will likely fail) or you're getting some really odd data returned.

Solution 2:

Need to run

Shadowbox.setup('h2 a');

This will reinitialise and bind it to any ajax loaded content

Post a Comment for "Jquery, Shadowbox And Ajax"