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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:04:57+00:00 2026-05-23T15:04:57+00:00

I am making a cross-domain JSON(P) call by using JavaScript to add a <script>

  • 0

I am making a cross-domain JSON(P) call by using JavaScript to add a <script> tag to the DOM with that URL I want included as the src. The script being loaded has a callback that calls a function on my page, and the data I want is returned as an argument to the function.

There are 2 catches, though:

  1. Sometimes the JSONP page will return a 400 or 404 error.
  2. The same JSONP file can be requested multiple times on the same page (each time returning different data)

So, I need to detect when the callback function is not fired (which would indicate that the JSONP file returned an error), but I also need to account for the fact that the same file can be requested twice. Essentially, I need to detect the error in loading the page, but I have to do it before the other files finish loading. And yes, the files should be loaded (or return an error) in the correct order.

One (inefficient) solution:

I could make a bunch of different functions that are requested for each different file load (eg. callbackFunction0, callbackFunction1, etc). That way, I can simply determine when one of the functions didn’t fire and have my JavaScript act off of that. However, this would take up a lot of space an be inefficient because I would have to have one callbackFunction for the maximum time the script would be loaded on the same page (this number has no definite value, though, so if I only made 15 functions and the script was requested 20 times, errors would occur).

This was kind of difficult to explain, but hopefully you got the idea. Thanks.

  • 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-23T15:04:58+00:00Added an answer on May 23, 2026 at 3:04 pm

    To solve this, I made the callback include a variable containing the request number. So the callback might be var requestnumber=0;callbackFunction. Then I could figure out which request applied to which element. I should have thought of this before.

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

Sidebar

Related Questions

I understand that for Silverlight to be able to make a cross-domain request using
I am trying to use the flXHR javascript library for making cross-domain calls. I
In an application where I am making cross-domain JSONP requests (using jQuery), when the
I am trying to call to the bit.ly URL shortening service using jQuery with
I am doing a cross domain request using $.ajax . It works on Firefox
I've got a Silverlight application that makes a cross-domain request. The clientaccesspolicy.xml file exists
I'm using CMake to create a visual studio project as I'm making a cross
I'm making a simple cross platform chat program. I'm using wXWidgets for the GUI
I'm making a cross domain POST request. I added Access-Control-* headers to the web
I have recently worked through a bunch of kinks making cross-domain ajax calls 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.