Skip to content

Commit

Permalink
modifying index.html to interact with server
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieroberts committed Aug 29, 2019
1 parent 176465e commit 8675c35
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
<!doctype html>
<html lang="en">
<head>
<title>CS4241 Assignment 2</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script src="js/scripts.js"></script>
</head>
<body>
<div class="header">
<h1>Assignment 2</h1>
</div>
<form action="">
<input type='text' id='yourname' value="your name here">
<button>submit</button>
</form>
</body>
<script>

<div class="content">
<p>
[Your content here]
</p>
</div>
const submit = function( e ) {
// prevent default form action from being carried out
e.preventDefault()

</body>
const input = document.querySelector( '#yourname' ),
json = { yourname: input.value },
body = JSON.stringify( json )

fetch( '/submit', {
method:'POST',
body
})
.then( function( response ) {
// do something with the reponse
console.log( response )
})

return false
}

window.onload = function() {
const button = document.querySelector( 'button' )
button.onclick = submit
}

</script>
</html>

0 comments on commit 8675c35

Please sign in to comment.