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

  • Home
  • SEARCH
  • 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 8367545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:11:13+00:00 2026-06-09T13:11:13+00:00

Why is that when i give alert inside the jquery block it runs other

  • 0

Why is that when i give alert inside the jquery block it runs other wise it doesn’t show any output?

  <script type="text/javascript">
(function map() {
var test = document.createElement('script'); 
    test.type = 'text/javascript'; 
    test.async = true;
test.src = 'myjsfile.js';
var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(test, s);
});
  </script>

I am trying to create a plugin and the script calls the myjsfile.js and will execute the functions inside it only is if i add alert() inside the above code.

  • 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-09T13:11:14+00:00Added an answer on June 9, 2026 at 1:11 pm

    If the code that you show is the first script tag on the document, I could see this maybe causing a problem:

    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(test, s);
    

    Why not append it directly to the head or body? More straightforward, in my opinion.

    (document.getElementsByTagName('head')[0]
     || document.getElementsByTagName('body')[0]).appendChild(test);
    

    Also, you may not be getting any output because you aren’t actually calling your function. Try this:

    <script type="text/javascript">
        (function map() {
            // Your code here
        })(); // Add () to call your function
    
        // Or, just call it the old fashioned way when you're done.
        map();
    </script>
    

    One other thing to watch out for, map is already a function within jQuery, so be cautious with your name spaces and how you try to call your function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a script that uses pynotify to give an alert. it works just
I have a table name that starts with an underscore does that give any
I have around 100 models, from MCMCglmm, that give output similar to this: >
Does anyone know of any resources that can give me an idea of how
How can I add script inside a php code? suppose i want to give
My code that give long month name instead short name: var monthShortName=$.datepicker.formatDate('MM d, yy',
I have a service that give me a date time string in the following
Is there a set of functions that give you the file and/or the folder
Alright, so i need to be able to match strings in ways that give
Give that I have written a JPanel with many different components on it, is

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.