Below is the required task :
- Make an Ajax post to server (eg. "http://192.168.1.107:80" )
- On response, make a get request to server asking for values
- Update input box with returned values.
Note : Page should not refresh during the process
Below is the required task :
Note : Page should not refresh during the process
Below CodePen can help you get started: Your query should also be resolved with this.
<html>
<input id='inp1' type='text'/>
</html>
<script>
var xhrObject = new XMLHttpRequest();
xhrObject.onreadystatechange = function() {
if (xhrObject.readyState === 4) {
if (xhrObject.status === 200 || xhrObject.status === 304) {
console.log(xhrObject.responseText);
var inp = document.getElementById('inp1');
inp.value = xhrObject.responseText;
}
}
};
xhrObject.open(
"GET",
"http://codepen.io/chriscoyier/pen/difoC.html",
true
);
xhrObject.send();
</script>
CodePen : http://codepen.io/anon/pen/LVKMOX