Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #--- this is the html
  2.  
  3. <html>
  4. <head>
  5. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  6. <script src="app.js"></script>
  7. <title>test</title></head>
  8. <body><form id="ajax-contact" method="post" action="http://142.93.116.203:8000/jackknife">
  9. <div class="field">
  10. <label for="values">Values</label>
  11. <input type="values" id="values" name="values" required>
  12. </div>
  13.  
  14. <div class="field">
  15. <label for="tails">Tails:</label>
  16. <input type="tails" id="tails" name="tails" required>
  17. </div>
  18.  
  19. <div class="field">
  20. <button type="submit">Send</button>
  21. </div>
  22. </form>
  23. <div id="form-messages"></div>
  24.  
  25. </body>
  26. </html>
  27.  
  28.  
  29. #---
  30.  
  31. #--- this is app.js
  32.  
  33. $(function() {
  34. // Get the form.
  35. var form = $('#ajax-contact');
  36.  
  37. // Get the messages div.
  38. var formMessages = $('#form-messages');
  39.  
  40. // TODO: The rest of the code will go here...
  41. });
  42.  
  43. .done(function(response) {
  44. // Make sure that the formMessages div has the 'success' class.
  45. $(formMessages).removeClass('error');
  46. $(formMessages).addClass('success');
  47.  
  48. // Set the message text.
  49. $(formMessages).text(response);
  50.  
  51. })
  52. .fail(function(data) {
  53. // Make sure that the formMessages div has the 'error' class.
  54. $(formMessages).removeClass('success');
  55. $(formMessages).addClass('error');
  56.  
  57. // Set the message text.
  58. if (data.responseText !== '') {
  59. $(formMessages).text(data.responseText);
  60. } else {
  61. $(formMessages).text('Oops! An error occured and your message could not be sent.');
  62. }
  63. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement