Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.  
  3.    
  4.     function postNS(e) {
  5.  
  6.     var email = $("input[type*='email']").val();
  7.     var phone = $("input[type*='tel']").val();
  8.     var topic = $(".content-box .form-group").eq(2).find("input").val();
  9.  
  10.  
  11.  
  12.    
  13.     var form = JSON.stringify({
  14.             email: email,
  15.             description: topic,
  16.             phone: phone,
  17.            
  18.         }
  19.     );
  20.     //metoda konwertująca stringi do jsona
  21.  
  22.     var url = 'sm_register2.php';
  23.     //url do php'a, który obsługuje wysyłkę do SM.
  24.  
  25.     // e.preventDefault(); - jeżeli nie chcemy odświeżać strony
  26.  
  27.     $.ajax({
  28.         type: "POST",
  29.         url: url,
  30.         headers:
  31.  
  32.         {
  33.             'Access-Control-Allow-Origin': '*',
  34.             'Accept': 'application/json',
  35.             'Content-Type': 'application/json'
  36.         },
  37.  
  38.         dataType: "json",
  39.         data: form,
  40.         success: function (data) {},
  41.         error: function (data)
  42.  
  43.         {
  44.             console.log("cos poszlo nie tak");
  45.         }
  46.     });
  47.  
  48. }
  49.  
  50. //zdarzenie na przycisk
  51. $(".primary-action").on('submit', function (e) { //co wywołuje wysyłkę do SM
  52.     postNS(e);
  53. });
  54.    
  55.    
  56. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement