Guest User

Untitled

a guest
Apr 12th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.72 KB | None | 0 0
  1.  
  2. var request;
  3.  
  4. $('.addEntry').submit(function (event) {
  5.  
  6.     if(validateBookYear() && validateBookAuthor() && validateBookName()) {
  7.  
  8.         var serializedData = $(this).serialize();
  9.  
  10.         if (request) {
  11.             request.abort();
  12.         }
  13.  
  14.         request = $.ajax({
  15.             url: "addBook.php",
  16.             type: "POST",
  17.             data: serializedData
  18.         });
  19.  
  20.         request.done(function (response, textStatus, jqXHR) {
  21.             console.log("sucess");
  22.         });
  23.  
  24.         request.fail(function (jqXHR, textStatus, errorThrown) {
  25.             console.error(
  26.                 "error: " +
  27.                 textStatus, errorThrown
  28.             );
  29.         });
  30.     }
  31.  
  32.     return false;
  33. });
Advertisement
Add Comment
Please, Sign In to add comment