I have a text box with submit button . I shall retrieve a number from the text box. I have to take this number and respond with a url in the format of url/number this way - like this it opens the website.But the code is not working.Please help.
<html>
<head>
<title>Numbers Ajax</title>
</head>
<body>
<script>
function loadDoc() {
var number=document.getElementById("text").value;
console.log(number);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 || this.status == 200) {
document.getElementById("ajax1").innerHTML = this.responseText;
console.log(this.responseText)
}
};
xhttp.open("GET", "http://numbersapi.com/number", true);
xhttp.send();
}
</script>
<div id="ajax1"></div>
<h1>AJAX </h1>
No.:
<input type="text" id="text" name="text" >
<button type="button" id="buttonnumber" onclick="loadDoc()">Submit</button>
</body>
</html>
"; . Now i am getting the o/p of a number twice. How get it only once – java_jazz Mar 13 '18 at 10:26
"; . But the output is appearing twice with this -->12 is the number of constellations in the ecliptic (or signs of the zodiac). 12 is the number of constellations in the ecliptic (or signs of the zodiac). How to avoid this – java_jazz Mar 13 '18 at 11:11