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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:25:46+00:00 2026-06-09T20:25:46+00:00

I have a javascript file from a wordpress plugin that I’m trying to modify.

  • 0

I have a javascript file from a wordpress plugin that I’m trying to modify. It seems to be getting away with cross-domain requests with some sort of loophole. It’s this function:

function urlCallback(url){
  var req = url;
  var head = document.getElementsByTagName("head").item(0);
  var script = document.createElement("script");
  script.setAttribute("type", "text/javascript");
  script.setAttribute("src", req);
  head.appendChild(script);   
}

The url passed is something like 'http://url.com/page?callback=namespace.myFunction' where myFunction is a function defined elsewhere in the script.

From what I understand, this is inserting a source url at the top of my page, causing the browser to load that page. The callback attached to that url is then called, passing the result as a single parameter to the example function, myFunction.

My problem is that I need to call myFunction for a few different unique urls, but the results are tied to the calling url. myFunction seems to be called whenever the page finishes loading, so I can’t simply keep count of which data set it’s operating on. I need some way for myFunction to either be passed an additional variable encoded in the callback url, or for myFunction to know the url it was attached to.

Can anyone help me?

EDIT:

To elaborate further, here is a simplified version of the code I have:

var parseUrls = (function(){
  function urlCallback(url){
    var req = url;
    // Here is where I need to save the url
    var head = document.getElementsByTagName("head").item(0);
    var script = document.createElement("script");
    script.setAttribute("type", "text/javascript");
    script.setAttribute("src", req);
    head.appendChild(script);   
  }

  return {
    options: {},
    parseNextUrl: function(result) {
        if (!result || !result.data) { return; }
        var data = result.data;
        // Here is where I need the url

    },
    parseUrl: function(result) {
      if (!result || !result.data) { return; }
      var data = result.data;
      for (var i = 0; i < data.length; i++) {
        urlCallback( data[i].url + "/new_url/page?callback=parseUrls.parseNextUrl" );
      }
    },
    showResult: function(options){
      urlCallback( "http://start.url.com/page?callback=parseUrls.parseUrl" );
      this.options = options;
    }
  };
})();

Just to be clear, parseNextUrl is called whenever the source request is finished. Which means all the urlCallback calls have already finished by then.

  • 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-09T20:25:47+00:00Added an answer on June 9, 2026 at 8:25 pm

    Here’s the updated code based on the newly provided code.

    var parseUrls = (function(){
      function urlCallback(url){
        // Create request
        var head = document.getElementsByTagName("head").item(0);
        var script = document.createElement("script");
        script.setAttribute("type", "text/javascript");
        script.setAttribute("src", req);
        head.appendChild(script);   
      }
    
      return {
        parsers: [], //response handler array
        options: {},
        parseUrl: function(result) {
          //parseUrls.parseUrl.url = request URL
    
          if (!result || !result.data) { return; }
          var data = result.data;
    
          // Create requests
          for (var i = 0; i < data.length; i++) {
            // Create new response handler
            var parseNextUrl = function(result) {
              // parseNextUrl.url = request URL
    
              if (!result || !result.data) { return; }
              var data = result.data;
    
              // Check the URL
              console.log('Result URL = ' + parseNextUrl.url);
            };
    
            // Make callback names and URLs for each handler
            var cbName = "parseUrls.parsers[" + this.parsers.length + "]";
            var req = data[i].url + "/new_url/page?callback=" + encodeURI(cbName);
    
            // Save the URL in the handler
            parseNextUrl.url = req;
    
            // Put handler into storage.
            // Note: Don't delete/insert any of parsers array element
            // until no more new requests and all responses are received.
            this.parsers.push(parseNextUrl);
    
            urlCallback(req);
          }
        },
        showResult: function(options){
          this.parseUrl.url = "http://start.url.com/page?callback=parseUrls.parseUrl";
    
          urlCallback(this.parseUrl.url);
          this.options = options;
        }
      };
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a section of a webpage that loads a JavaScript file from an
Hey. I have this javascript file that I'm getting off the web and it
I have a javascript file. how can i reference that file from within XSLT.
I have a site on domainA.com. It includes file.js from domainB.com: <script type=text/javascript src=http://www.domainB.com/file.js></script>
I have a JavaScript file that prints the title attribute of the child img
I have a JavaScript file that I ran through the Google Closure compiler, and
I have an external Javascript file and i am trying to alert the value
I have a javascript file with a global object that must not be renamed
I'm having problems trying to call a Javascript function from an enqueued javascript file
I have a javascript file that I minify using the Yahoo YUI. When 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.