Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:03:12+00:00 2026-06-15T14:03:12+00:00

in my .js file which will be using by external users I want to

  • 0

in my .js file which will be using by external users I want to check if on their’s page the jQuery lubrary is loaded. To do so, I’m using:

if (!window.jQuery) {
    var script = document.createElement('script');
    script.type = "text/javascript";
    script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
    document.getElementsByTagName('head')[0].appendChild(script);
}    

$(document).ready(function () {
    //do some jquery $.ajax({}); stuff
});

but, at the $(document).ready(function () { line I get the error message ReferenceError: $ is not defined How to fix it ?

edit:

I’ve added the line

if (!window.jQuery) {
    ...
    document.getElementsByTagName('head')[0].appendChild("<script type='text/javascript'>$(document).ready(function () {...});</script>");
} 

and now I get the NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMHTMLHeadElement.appendChild]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:03:13+00:00Added an answer on June 15, 2026 at 2:03 pm

    Remove the document.ready part, and, in a separate script tag beneath the one you are using to append jQuery to the head, do this:

    <script>
     window.onload = function() {
       //do the same code in here as you would've done in document.ready
     }
    </script>
    

    EDIT

    The comment below makes a good point…in that case, you do this:

    <script>
     (function() {
         var load = function() {
           //do the same code in here as you would've done in document.ready
         };
    
         if(window.addEventListener) {
            window.addEventListener('load',load);
         } else {
            window.attachEvent('onload',load);
         }
     }());
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code which will generate a wav file which contains a
i am generating *.reg file using code which will have some important data. and
I have a PHP file which my clients will execute on their server. It
I have a PHP file which will return something like <div id=title>Add Us On
I have a Batch file which will call a Powershell Script : BATCH FILE
I need to create a batch file which will copy web log files from
I'm trying to put a large table in a pdf file which will be
I've list of states and a php file which will list all the city
I have a app which will download a file from web. The download action
I have a webview which will load from file or from the web. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.