Forums

[resolved] External JS, JQuery (2 posts)

  1. lelek
    Member
    Posted 1 year ago #

    Hi!

    I've got a problem with wp_enqueue_script (or just include JS script on my site).
    Call of method with wp_enqueue_script:

    <?php wp_enqueue_script('jquery')
        $path = get_bloginfo("template_url")."/banner/simpe.js";
        wp_enqueue_script("dupa", $path);
        wp_head();
    ?>

    causes inclusion of text:

    <script type='text/javascript' src='http://localhost/WPL/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
    <script type='text/javascript' src='http://localhost/WPL/wp-content/themes/main/banner/simple.js?ver=3.0'></script>

    but the error console in Firefox tells me that my function is non definied. I also tried to include script in the same file where is the call of its method - then everything is ok.

    Call of my method in file:

    <script type="text/javascript">
       var $j = jQuery.noConflict();
       $j(document).ready(function() {
         simple();
       });
    </script>

    and external file:

    function simple() {
       alert("i'm here");
    }

    What am I doing wrong? Please help me, codex haven't helped and google too :-).
    Thanks in advance.

  2. lelek
    Member
    Posted 1 year ago #

    I've just realised that I have to put my JS external file in wp-includes/js.
    It won't be working when it is elsewhere.
    But I have no idea why and where is the information about this fact in WordPress Codex.

Topic Closed

This topic has been closed to new replies.

About this Topic