Advertisement
Guest User

Untitled

a guest
May 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. $('#save-form').submit(function (e) {
  2. e.preventDefault();
  3.  
  4. //serialize form data
  5. var postData = $('#save-form').serialize();
  6. //form the request
  7. var req = $.ajax({
  8. url: "save_game.php",
  9. type:"post",
  10. data: postData
  11. });
  12.  
  13. //registering callbacks
  14. req.done(function (res, txtStatus, jqXHR) {
  15. //code executed on request success
  16. alert(res.msg);
  17. });
  18.  
  19. req.fail(function (jqXHR, txtStatus, error) {
  20. //code executed on request error
  21. console.error("The following error occurred: "+textStatus, errorThrown);
  22. });
  23.  
  24. req.always(function () {
  25. //code that executed always per request
  26. });
  27. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement