I just created a HTML file and that file has a link that goes to the server and retrieves the value that is a number.
I am just wondering that can we have that value that is generated by link in that alert box.
To be clear I dont want link in alert box but I want to display the value that is returned from the server
See here my code
<!DOCTYPE html>
<html>
<body>
<p>Click the button to display an alert box:</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
alert("I am an alert box!");
}
</script>
<a href="http://localhost:8080/TemperatureReading/"> test </a>
</body>
</html>
Here alert box is saying-
I am an alert box!
Now, what I want is can I have value showing in alert box which is the value from the server( the value which is in the link).
This can be very easy but I am not able to get it. Can anyone help me on this issue. Thank you in advance!
EDIT: I have also tried ajax GET request--
<!DOCTYPE html>
<html>
<body>
<h2>AJAX</h2>
<button onclick="myFunction()">Try it</button>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("demo").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "http://localhost:8080/TemperatureReading/", true);
xhttp.send();
}
</script>
</body>
</html>
But where to have alert??
` element?
– Jamiec May 17 '16 at 08:38`? That is incredible! I think you're just after someone to hold your hand!
– Jamiec May 17 '16 at 09:36