I am new to JavaScript and looking to explore the potential of XMLHttpRequest.responseText
with a specified URL. Can someone guide me on how to efficiently test this?
let url = "http://m.google.com/"; <br>
let xmlHttp = new XMLHttpRequest(); <br>
xmlHttp.open('GET', url, true); <br>
document.getElementById('main-content').innerHTML = xmlHttp.responseText; <br>
The element with an id of main-content
is a <div>
. By executing the last line of code, the contents of the <div>
will be replaced by the output from xmlHttp.responseText
.
If I were to access the source of m.google.com
through my regular browser and view its code, which segment would occupy the <div>
tag? Also, in what environment should I implement this piece of code for testing purposes?
Just to elaborate, I have an Android application that renders the HTML result within a WebView
.