Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <!doctype HTML>
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Ajax test</TITLE>
  5.  
  6.  
  7. <script>
  8. function sendAjax(){
  9. console.log("sendAjax function was called");
  10. var data = {
  11. user : {
  12. userID : "5",
  13. username : "a_test_user",
  14. phoneCred : "111",
  15. won : "0",
  16. lost : "0",
  17. previousGamePlace : "0",
  18. leagueID : "0",
  19. rosterID : "0"
  20. }
  21. };
  22.  
  23. var req = new XMLHttpRequest();
  24. req.open('POST', 'http://cryptic-waters-6734.herokuapp.com/users.json', true);
  25. req.setRequestHeader("Content-Type","application/json");
  26. req.setRequestHeader("Accept","application/json");
  27. req.send(JSON.stringify(data));
  28. console.log("executed through sending request, check heroku app for new entry");
  29. }
  30. </script>
  31. <style>
  32. .container {
  33. width:80%;
  34. height: auto;
  35. margin: 5% auto;
  36. border: 1px solid black;
  37. }
  38. </style>
  39. </HEAD>
  40. <BODY>
  41. <div class="container">
  42. <button onclick="sendAjax()">AJAX</button>
  43. </div>
  44.  
  45. </BODY>
  46. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement