I am new to JavaScript. I need to test the output of XMLHttpRequest.responseText on a given URL. What is the simplest way to do it?
var url = "http://m.google.com/"; <br>
var xmlHttp = new XMLHttpRequest(); <br>
xmlHttp.open('GET', url, true); <br>
document.getElementById('main-content').innerHTML = xmlHttp.responseText; <br>
main-content is a <div> tag. The last line of code will replace the contents of the <div> tag with output of xmlHttp.responseText.
Now, when I open m.google.com in my regular browse and select “View Source”, what part of the source gets placed within the <div> tag. Or let’s stay I have to test this code in – where do I write this code?
Actually, I have an Android app that displays this HTML code result in a WebView.
Skip your frustrations and employ jQuery. It’s an industry standard and almost every employer asks if you have experience with it.
However, if you want a go a more difficulte route: