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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:34:11+00:00 2026-06-02T13:34:11+00:00

I am trying to get variables from an external domain using ajax and then

  • 0

I am trying to get variables from an external domain using ajax and then create pre-filled form fields with the data, but i cant seem to get it to work.

I am a bit of a noob to JavaScript it might be something stupid but i just can’t figure out why it is not working.

 <html>
<head>
<script type="text/javascript">
    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 counter = 1;
    var limit = 3;
    var txt = '';

    for(var key in data) {

          var newdiv = document.createElement('div');
          newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='myInputs[]' value=" + data[key] +">";
          document.getElementById(divName).appendChild(newdiv);
          counter++;
;
        }
    }

    var url = "http://myserver.com/test.php";

</script>
<title></title>
</head>
<body>
<button onclick="xss_ajax(url);">Get Data</button>
</body>
</html> 

The script on the external domain.

callback({"firstname":"John", "lastname":"Smith", "email":"john.smith@johnsmith.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-02T13:34:13+00:00Added an answer on June 2, 2026 at 1:34 pm

    You need to look into JSONP. Also using a library to handle the request will help exponentially, checkout jQuery or Extjs. Heres a blog post that should give you a hand.

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

Sidebar

Related Questions

I'm trying to get data for my application from a form set in an
I'm trying to get the hang of using variables in C#, but have hit
I've been trying to get this really simple example of using AJAX with JQuery
I'm trying to load data from a text file on my server using the
I'm trying to display my get variables as flat links. Want to change from
I have this code - which is trying to get variables from the URL
I am trying to get the contents of tags into variables in my java
I am trying to maintain my session variables that I get back in a
I'm trying to access a member structs variables, but I can't seem to get
I'm trying to get the value of a variable using SQL select queries. Nothing

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.