1

Dear Friends i used jquery for drop down menu with scroll bar js plugin. when i load script like.

<script src="js/jquery.dd.js"></script>

it working properly.

but when i try to load is not working.

$.getScript( "js/jquery.dd.js", function( data, textStatus, jqxhr ) {
    console.log( data ); // Data returned
    console.log( textStatus ); // Success
    console.log( jqxhr.status ); // 200
    console.log( "Load was performed." );
});

i try to load js file to runtime but is not working. please help. Thanks.

Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106
  • You must surely be getting some kind of error. (Not my dv) – T.J. Crowder Oct 16 '13 at 13:21
  • I would imagine the issue is because the `dd.js` script is designed to run on the document.ready event, yet this has already happened before you call `getScript`, therefore the plugin is never instatiated. – Rory McCrossan Oct 16 '13 at 13:22
  • 1
    Please define "not working". What do you expect, and what happens instead? – Luca Rainone Oct 16 '13 at 13:23
  • @T.J. Crowder yes no i not got any error file load successfully but combo box is not design with scroll. it lokk like simple. –  Oct 16 '13 at 13:24
  • 2
    @RoryMcCrossan: Actually if you bind to document.ready after it's already ready, then the callback is just ran immediately. – gen_Eric Oct 16 '13 at 13:29
  • @RocketHazmat fair enough then. I can't say I've ever nested ready handlers to try it :) – Rory McCrossan Oct 16 '13 at 13:32
  • 2
    @RoryMcCrossan: Yeah, there's actually a "gotcha" waiting there: If you pass a ready handler to jQuery but the ready event has already fired, the handler is called *synchronously* (whereas if the event hasn't already run, naturally the call is asynchronous). So depending on what you're doing after you register the handler... I reported it as a bug, but while they agreed it wasn't ideal, they decided not to change it. :-) – T.J. Crowder Oct 16 '13 at 13:34
  • When you call the plugin `$('.selector').dd()`? You should call it inside the callback (after your console.log) – Luca Rainone Oct 16 '13 at 14:30

1 Answers1

4

May your Scripts are not sequenced try this,

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
    $(function(){
        $.getScript( "js/jquery.dd.js", function( data, textStatus, jqxhr ) {
            console.log( data ); // Data returned
            console.log( textStatus ); // Success
            console.log( jqxhr.status ); // 200
            console.log( "Load was performed." );
        });
    });
</script>

Demo may help you

Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106
  • 3
    @Developer -- Please give a description of what happens, "not working" is the single least informative statement :\ – tymeJV Oct 16 '13 at 13:26
  • i have jquery plugin to design my combo box with scroll. but when i load script using getScript is load successfully but my combo box is not design with scroll it look like simple. –  Oct 16 '13 at 13:28
  • how to add more js plugin files with/using $.getscript() and how to initialize it? – Ponnaveen S Feb 05 '19 at 09:02