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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:44:25+00:00 2026-05-16T23:44:25+00:00

I have the following code. var d3_ad = 1; function displayD3Ad(){ var query_string =

  • 0

I have the following code.

    var d3_ad = 1;

    function displayD3Ad(){
        var query_string = '?d3_ad='+d3_ad;
        query_string += '&location='+escape(location);

    //document.write('<iframe src="index.php'+query_string+'"></iframe>');

    var data = httpRequest('http://localhost/test/index.php','GET',query_string);
    document.write(data);
}

function httpRequest(strURL,type,query) {
    var request = false;

    if (window.XMLHttpRequest) {// Mozilla/Safari
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { //Internet Explorer
        request= new ActiveXObject("Microsoft.XMLHTTP");
    }

    request.open(type, strURL + query, true);
    request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    request.onreadystatechange = function() {
        if (request.readyState == 4) {
            return request.responseText;
        }
    }

    request.send(null);
}

displayD3Ad();

now when it writes out the data it is saying undefined. It seems like it isnt returning the data. I looked in firebug and it completes and shows the response that shoudl be there. Any help is appreciated. I just need to set the data variable so that I can use it later on.

  • 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-16T23:44:25+00:00Added an answer on May 16, 2026 at 11:44 pm

    You’re right, in JavaScript you’d have to handle the response value in a callback. Which is not ideal for serious application.

    There is an extension to the JavaScript language called StratifiedJS. It runs in every browser, and it allows you to get the response value directly (instead of undefined)

    You can enable Stratified JavaScript e.g. by including Oni Apollo ( http://onilabs.com/docs ) in your webpage like:

    <script src="http://code.onilabs.com/latest/oni-apollo.js"></script>
    <script type="text/sjs"> your StratifiedJS code here </script>
    

    And the your code would look like this:

    function displayD3Ad(){
      var query_string = '?d3_ad='+d3_ad;
      query_string += '&location='+escape(location);
    
      var data = require("http").get('http://localhost/test/index.php' + query_string);
      document.write(data);
    }
    

    This is using the Apollo toolkit so you don’t have to write your own HttpRequest function, it’s already there in the “http” module.

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

Sidebar

Ask A Question

Stats

  • Questions 540k
  • Answers 540k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The newest versions of Jmeter have a fantastic sampler called… May 17, 2026 at 2:29 am
  • Editorial Team
    Editorial Team added an answer I like the idea of putting the error messages in… May 17, 2026 at 2:29 am
  • Editorial Team
    Editorial Team added an answer No, there isn't. There's a little bit of explanation here.… May 17, 2026 at 2:29 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following code: var tempIdx = document.getElementById('cityBuild').selectedIndex; var tempBuilding = document.getElementById('cityBuild').options[tempIdx].value; //
I have the following code var input = $('#el_id'); wrapper = $(document.createElement('div')); wrapper.addClass('small'); wrapper.css('width',200);
I have the following code: var from = 0, step = 5; function showNext(list)
I have the following code: var tagToPosts = (from t2p in dataContext.TagToPosts join t
I have the following code: var sl: THashedStringList; begin sl:= THashedStringList.Create; sl.Duplicates := dupIgnore;
I have the following code: var items = new List<string> {1, 2, 3}; //
I have the following code: var devices = from d in ctx.Devices.Include(DeviceGroups) where d.DeviceEnabled
I have the following code: var inp = $(#txt); if(inp.val() != ) // do
I have the following code: var entityConnection = (System.Data.EntityClient.EntityConnection)c.Connection; DbConnection conn = entityConnection.StoreConnection; ConnectionState
I have the following code: var personIds = from player in myPlayers select player.person_id;

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.