JavaScript javascript get html file from online link javascript html file to string,javascript html file upload,javascript

i want to call a html online link using xmlhttprequest with javascript, here is my code but when the code arrive to xmlhttp.open it stopped and does not continue the execution

function loadXMLDoc(size,downloadfromurl) {
    var xmlhttp;

    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else {
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {

        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            var temp = xmlhttp.responseText;

        }
    }

    xmlhttp.open("GET", "http://app.arsel.qa/mobileappspeedtest/samples/256.htm?n=" +  Math.random(), false);

    xmlhttp.send(null);

}
Answer:1

What you are doing is an actual AJAX request to that page. Cross domain AJAX requests are not allowed by default for security reasons. However, there are several ways of performing cross domain requests, and you could take a look at how jQuery does it, so you don't have to reinvent the wheel all over again using plain JavaScript. This article should be helpful.

Anyway, if you actually want to crawl that page, there are tons of open source libraries for server side scripting languages like Java, PHP, Node.js, etc that are very useful in gathering the content, parsing the HTML and so on, depending on your needs.

Answer:2

guys, I am playing arround with HTML5 and javascript. The current thing which I am making is the following: there is a purple block on the screen and when you click a button it is moved 100 pixels to ...

guys, I am playing arround with HTML5 and javascript. The current thing which I am making is the following: there is a purple block on the screen and when you click a button it is moved 100 pixels to ...

  1. html5 javascript function
  2. html5 javascript function parameters
  3. html5 javascript function example
  4. html5 call javascript function
  5. html5 onclick javascript function
  6. html5 call javascript function on page load
  7. html5 href javascript function
  8. html5 button javascript function
  9. html5 execute javascript function
  10. html5 run javascript function
  11. html5 button call javascript function
  12. html5 button onclick javascript function
  13. html5 call external javascript function
  14. html5 form action javascript function
  15. html5 button onclick call javascript function
  16. html5 form action call javascript function

I am trying to create a javascript algorithm for an ul menu that stretches out li elements to use the available width (100%). I was thinking about an algorithm with this flow: 1. calculate the ...

I am trying to create a javascript algorithm for an ul menu that stretches out li elements to use the available width (100%). I was thinking about an algorithm with this flow: 1. calculate the ...

Below is the code where I am disabling ENTER button. $(document).ready(function () { $(window).keydown(function (event) { if ((event.keyCode == 13) && ($('#btnsubmit').disabled)) ...

Below is the code where I am disabling ENTER button. $(document).ready(function () { $(window).keydown(function (event) { if ((event.keyCode == 13) && ($('#btnsubmit').disabled)) ...

I want three lines of text to appear in a succession, then hide, and then appear in succession again. So far, I have been able to split the lines into span tags and appear in succession, but I can't ...

I want three lines of text to appear in a succession, then hide, and then appear in succession again. So far, I have been able to split the lines into span tags and appear in succession, but I can't ...