JAVASCRIPT   24

regCheck js

Guest on 13th June 2022 04:51:33 PM

  1. function checkIfExisting(dob, first, last, school) {
  2.     var returnval = false;
  3.     jQuery.ajax({
  4.         async: false,
  5.         url: "getContactFromCriteria.php",
  6.         data: {
  7.             DOB: dob,
  8.             First: first,
  9.             Last: last,  
  10.             School: school
  11.         },
  12.         contentType: "application/json",
  13.         dataType: "json",
  14.         success: function (contact) {
  15.             if(contact && contact[0] && contact[0].id) {
  16.                 alert("We've matched your data in our system and it looks like you have registered before.\nPlease go back and select 'I have been a Member Before.'");
  17.                 returnval = true;
  18.             }
  19.         },
  20.         error: function (jqXHR, textStatus, errorThrown) {
  21.             if ('code' in jqXHR.responseJSON && 'message' in jqXHR.responseJSON){
  22.                 var errMsg = "";
  23.                 if (jqXHR.responseJSON['code'] == '330'){
  24.                     errMsg = "Too many request";
  25.                 }else{
  26.                     errMsg = jqXHR.responseJSON['code'] + ": " + jqXHR.responseJSON['message'];
  27.                 }
  28.                 alert("ERROR:" + errMsg + "\r\n" + "Please try again.");
  29.             }else{
  30.                 alert("ERROR: jqXHR" + textStatus + "errorThrown" + errorThrown);
  31.             }
  32.             returnval = false;
  33.         }
  34.     });
  35.     return returnval;
  36. }

Raw Paste


Login or Register to edit or fork this paste. It's free.