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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:12:05+00:00 2026-06-01T14:12:05+00:00

I am using this Ajax script below to make cross domain Ajax calls which

  • 0

I am using this Ajax script below to make cross domain Ajax calls which works fine if i use alert(txt);, but when i change it to document.write(txt); to print the result it stops working and i am not sure why it is not working,

It might be something stupid but i just can’t figure it out

    function xss_ajax(url) {
        var script_id = null;
        var script = document.createElement('script');
        script.setAttribute('type', 'text/javascript');
        script.setAttribute('src', url);
        script.setAttribute('id', 'script_id');

        script_id = document.getElementById('script_id');
        if(script_id){
            document.getElementsByTagName('head')[0].removeChild(script_id);
        }

        // Insert <script> into DOM
        document.getElementsByTagName('head')[0].appendChild(script);
    }

    function callback(data) {
        var txt = '';
        for(var key in data) {
           txt += key + "  " + data[key];

        }
      //alert(txt);
      document.write(txt);
   }

    var url = "http://myserver.com";
  • 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-01T14:12:06+00:00Added an answer on June 1, 2026 at 2:12 pm

    I believe that in some browsers you cannot call document.write after the document is done loading…

    Edit: This stuff I’m striking out certainly does not work. As Teemu points out, calling “open” clears out the document. Also, MDN says that calling .write will implicitly call .open if you did not call it yourself. The other possibility is that the document is just not rendering because when you start writing you’ll have to close the stream. You could try (not really sure if this works):

    document.open();
    document.write('stuff');
    document.close();
    

    However, I would strongly recommend that you just use a more standard method for writing to the document such as appendChild or using a framework (e.g. jQuery):

    function callback(data) {
        var txt = '';
        for(var key in data) {
           txt += key + "  " + data[key];
    
        }
        //alert(txt);
        //document.write(txt);
        document.body.appendChild(document.createTextNode(txt));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am loading feed-items into a ul using this jQuery .ajax() call, which I
I am trying to make two ajax requests in parallel using jQuery like this:
I am using an ajax call which is as follows var ID=$(this).attr('id'); var input=$(#input_+ID).val();
I am using the script shown below. <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js' type='text/javascript'> <script type='text/javascript'> var sidebarnameacc1=&quot;sidebar&quot;;
i have this jQuery-AJAX code below and a form: <script type=text/javascript> $(document).ready(function () {
I am using this JQuery Ajax Voting system guide as a rough reference but
I have grabbed some XML data using this piece of jQuery: $.ajax({ type: POST,
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
This is the first time ever I'm using AJAX, and I want to do
I am using the ASP.NET AJAX Control Toolkit. Within this toolkit, I am only

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.