SHARE
TWEET

Untitled

a guest Jul 21st, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html lang="en">
  2.  
  3. <head>
  4.   <title>Szyfrowanie</title>
  5.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.   <meta name="description" content="Opis strony">
  7.   <meta name="author" content="Administrator">
  8.   <meta name="keywords" content="JavaScript">
  9.  
  10.   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
  11.   <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  12. </head>
  13.  
  14. <body>
  15.   <nav>
  16.   <div class="form">
  17.     <input type="button" id="button" name= "send">send
  18.   </div>
  19. </nav>
  20.  
  21.   <form id="target" action="encript_decript.php" method="POST">
  22.     <button id= "send" onclick="sendToPHP()">wyślij</button>
  23.   </form>
  24.  
  25.   <script type="text/javascript">
  26.  
  27.     // Struktura obiektu
  28.     const obj = {
  29.       name: "Marcin",
  30.       pet: {
  31.         name: "Lucek",
  32.         color: "brown",
  33.         speed: 100
  34.       }
  35.     };
  36.  
  37.     // Obiekt do wysłania
  38.     $.ajax({
  39.         url:         "encript_decript.php",
  40.         method:      "post",
  41.         contentType: "application/json",
  42.         data:         JSON.stringify(obj),  // Zamiania obiektu 'obj' na string.
  43.         dataType:    "json"
  44.       })
  45.       .done(function(res) {
  46.         console.log(res); //dostaliśmy odpowiedź z serwera, wypisujemy ją
  47.       })
  48.       .fail(function() {
  49.         alert("Wystąpił błąd w połączeniu");
  50.       });
  51.  
  52.  
  53.     /*
  54.     function sendToPHP(data) {
  55.       $(data).ready(function() {
  56.           $('#send').val(obj);
  57.           $('#target').submit();
  58.       });
  59.     }
  60.    */
  61.  
  62.   </script>
  63.  
  64. </body>
  65.  
  66. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top