Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.     $('#doador').on('submit', function(e){
  3.         e.preventDefault();
  4.         let nome = $('#nome').val();
  5.         let sangue = $('#sangue').val();
  6.  
  7.         $.ajax( {
  8.             url: "https://api.mlab.com/api/1/databases/projetos2b/collections/doador?apiKey=ICkpvj9dWKplTm2MzyjvMGNZsrB_ZlMu",
  9.             data: JSON.stringify({
  10.                 "nome" : nome,
  11.                 "sangue": sangue
  12.             }),
  13.             type: "POST",
  14.             contentType: "application/json",
  15.             success: function(data){
  16.                 window.location.href="index.html"
  17.              },
  18.              error: function(xhr, status, err){
  19.                 console.log(err);
  20.              }
  21.          });
  22.     });
  23. });
  24. //o erro deve começar por aqui!
  25. $(document).ready(function(){
  26.     $('#receptor').on('submit', function(f){
  27.         f.preventDefault();
  28.         let nomer = $('#nomer').val();
  29.         let hosp = $('#hosp').val();
  30.         let sanguer = $('#sanguer').val();
  31.  
  32.         $.ajax( {
  33.             url: "https://api.mlab.com/api/1/databases/projetos2b/collections/receptor?apiKey=ICkpvj9dWKplTm2MzyjvMGNZsrB_ZlMu",
  34.             data: JSON.stringify({
  35.                 "nome" : nomer,
  36.                 "hospital": hosp,
  37.                 "sangue": sanguer
  38.             }),
  39.             type: "POST",
  40.             contentType: "application/json",
  41.             success: function(data){
  42.                 window.location.href="index.html"
  43.              },
  44.              error: function(xhr, status, err){
  45.                 console.log(err);
  46.              }
  47.          });
  48.     });
  49. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement