0

I have an argument in JS which holds pretty much the data. It's the server information to my server. It changes often, e.g 20/64 or 32/64. You get the point.

I am trying to get the contents of the data to go on an external site, however, when I try, it doesn't work.

To summerise, I have a div which holds the data, I want to get that data using JS and put it on an external site which isn't using the same domain or web server.

HTML FILE:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <script src="jquery.js" type="text/javascript"></script>
</head>
<body>
    <div id="serverstats-wrapper"></div>
    <script src="import.js"></script>
</body>

JS File:

        $(document).ready(function(){
            $.post("query.php", {}, 
                function (data) {
                    $('#serverstats-wrapper').html (data);
                });
        });

        var the_main = document.getElementById("serverstats-wrapper");
        var the_data = the_main.textContent ? the_main.textContent : the_main.innerText;

I want to get the text from the html file to the js file then take it to an external website.

tasid
  • 1
  • 1

2 Answers2

0

Tasid! This won't work! JS does't have such a technique implementet. To do so, you need node.js. This allows you to send the data over a socket to your other webserver. It does't work difrently, because JS is executed direct on your PC.

ghnome
  • 57
  • 7
0

You can grab data from another site; but you cannot inject JS code into another site. Here are some methods to retrieve html from another site: Include another HTML file in a HTML file

Community
  • 1
  • 1
Kursad Gulseven
  • 1,948
  • 1
  • 23
  • 25