|
@@ -30,6 +30,9 @@
|
|
|
<button class="blue" type="submit">Say hello again</button>
|
|
<button class="blue" type="submit">Say hello again</button>
|
|
|
</form>
|
|
</form>
|
|
|
<button class="red" id="clearForm" type="button">Clear form</button>
|
|
<button class="red" id="clearForm" type="button">Clear form</button>
|
|
|
|
|
+
|
|
|
|
|
+ <div id="ajax"></div>
|
|
|
|
|
+ <button class="blue" id="getAjax" type="button">Get HTML with Ajax</button>
|
|
|
</div>
|
|
</div>
|
|
|
<script src="js/vendor/modernizr-3.5.0.min.js"></script>
|
|
<script src="js/vendor/modernizr-3.5.0.min.js"></script>
|
|
|
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
|
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
|
@@ -48,6 +51,7 @@
|
|
|
var input = document.getElementById('inputName');
|
|
var input = document.getElementById('inputName');
|
|
|
var clearButton = document.getElementById('clearForm');
|
|
var clearButton = document.getElementById('clearForm');
|
|
|
var dateSpan = document.getElementById('todaysDate');
|
|
var dateSpan = document.getElementById('todaysDate');
|
|
|
|
|
+ var ajaxButton = document.getElementById('getAjax');
|
|
|
|
|
|
|
|
function sayHelloAgain(e) {
|
|
function sayHelloAgain(e) {
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
@@ -66,8 +70,20 @@
|
|
|
showDate();
|
|
showDate();
|
|
|
setInterval(showDate, 1000);
|
|
setInterval(showDate, 1000);
|
|
|
|
|
|
|
|
|
|
+ function loadDoc() {
|
|
|
|
|
+ var xhttp = new XMLHttpRequest();
|
|
|
|
|
+ xhttp.onreadystatechange = function() {
|
|
|
|
|
+ if (this.readyState == 4 && this.status == 200) {
|
|
|
|
|
+ document.getElementById("ajax").innerHTML = this.responseText;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ xhttp.open("GET", "some-text.html", true);
|
|
|
|
|
+ xhttp.send();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
form.onsubmit = sayHelloAgain;
|
|
form.onsubmit = sayHelloAgain;
|
|
|
clearButton.onclick = clearForm;
|
|
clearButton.onclick = clearForm;
|
|
|
|
|
+ ajaxButton.onclick = loadDoc;
|
|
|
</script>
|
|
</script>
|
|
|
</body>
|
|
</body>
|
|
|
</html>
|
|
</html>
|