Issues using $.ajax

Posted by Nimbuz on Stack Overflow See other posts from Stack Overflow or by Nimbuz
Published on 2010-05-22T13:08:43Z Indexed on 2010/05/22 13:20 UTC
Read the original article Hit count: 301

Filed under:
|
|
|
|

I want to load the lightbox javascript only when a certain condition is satisfied so I'm loading it using $.ajax like so:

$.ajax({ url: "../static/js/lightbox.js", dataType: 'script', cache: true, success: function() {
    alert('loaded');
    $("a.lightbox").lightbox({
        opacity: "0.6",
        width: "940"
    });
}});

I see the "loaded" alert but the lightbox does not work. However, when I load the file directly (script src) from the HTML, lightbox works. How do I fix this?

Many thanks for your help.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery