Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype HTML>
- <HTML>
- <HEAD>
- <TITLE>Ajax test</TITLE>
- <script>
- function sendAjax(){
- console.log("sendAjax function was called");
- var data = {
- user : {
- userID : "5",
- username : "a_test_user",
- phoneCred : "111",
- won : "0",
- lost : "0",
- previousGamePlace : "0",
- leagueID : "0",
- rosterID : "0"
- }
- };
- var req = new XMLHttpRequest();
- req.open('POST', 'http://cryptic-waters-6734.herokuapp.com/users.json', true);
- req.setRequestHeader("Content-Type","application/json");
- req.setRequestHeader("Accept","application/json");
- req.send(JSON.stringify(data));
- console.log("executed through sending request, check heroku app for new entry");
- }
- </script>
- <style>
- .container {
- width:80%;
- height: auto;
- margin: 5% auto;
- border: 1px solid black;
- }
- </style>
- </HEAD>
- <BODY>
- <div class="container">
- <button onclick="sendAjax()">AJAX</button>
- </div>
- </BODY>
- </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement