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 6653867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:19:18+00:00 2026-05-26T01:19:18+00:00

I have Js Src code that contain Jsonp api functions. Where ever this Js

  • 0

I have Js Src code that contain Jsonp api functions. Where ever this Js Src code got printed i got to check first if the “api tag” printed already , if it did -> execute the api function , if the “api tag” have not got printed yet , wait for the tag to get printed on the screen and then execute the api functions.

for example i have this code

<html>
  <head>
    <!-- js code - contain Jsonp functions -->
    <script type="text/javascript" src="jsonp.js"></script>
  </head>

  <body>
    <!-- when this newtag get print , the function starts -->
    <newtag:api size="small">myNewTag</newtag:api>
  </body>

I don’t know where the user will decide to put the JS code , it may be in the head , body or in the middle of the page , since i have this mystery i cant do something like this :

<newtag:api size="small">myNewTag</newtag:api>
<script> startJsonp(); </script>

because if the js code did not printed yet the order will not be execute.

and if the Js code got print in the head so it will not work since the “api tag” did not got printed yet.

to make the api work i need the “api tag” to be printed on the screen already for the Jsonp functions to work.

what i can do to solve this?


what is the porpoise to write JS function like that?

(function(){
  // do something
})();

thank you so much!

  • 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-05-26T01:19:19+00:00Added an answer on May 26, 2026 at 1:19 am

    There are several solutions for this problem:

    • Using jQuery’s ready function. E.g.:

      jQuery.ready(function(){ startJsonp(); })

    • Using window.onload. The problem is that you can unintended override another window.onready function. E.g.:

      window.onready = startJsonp();

    • Using document.addEventListener and document.attachEvent. Eg.:

      if (document.addEventListener){
      document.addEventListener(‘load’, startJsonp, false);
      } else if (el.attachEvent){
      document.attachEvent(‘onload’, startJsonp);
      }

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

Sidebar

Related Questions

This standard code for an IFRAME, is there a way to replace the src
I have searched quite a bit on the web and on this site and
I have been attempting to do this for about a week. Every single time
I was wondering about the best way to tackle this. I'm trying to save
I'm building an app with Adobe AIR that contains a browsing component with mx:HTML
I have a menu on my page which changes the source of a particular
I'm trying to paginate an image gallery using jquery. The image directory I'm using
I believe the issue below relates to variable scope, although I may be mistaken.
Something with echo $facebook->init(); is causing my site to refresh over and over again
Short Version: I write an 8 byte, byte array filled with random bytes to

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.