Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>TimeJson</title>
  4. <meta charset="utf-8"/>
  5. <link rel="stylesheet" href="./jquery-ui-1.12.1.custom/jquery-ui.css">
  6. <script type="text/javascript" src="./jquery-ui-1.12.1.custom/external/jquery/jquery.js"></script>
  7. </head>
  8. <body>
  9. <button id="timeButton" onclick="timeAjax()" value='time'>Time</button>
  10. <button id="dateButton" onclick="timeAjax()" value='date'>Date</button>
  11. <div class="wyniki"></div>
  12.  
  13. {literal}
  14. <script type="text/javascript" language="javascript">
  15. //Ajax
  16.  
  17. function timeAjax() {
  18.  
  19. $(document).ready(function () {
  20. $("#timeButton").click(function () {
  21. var method = document.getElementById("timeButton").value;
  22. });
  23. $("#dateButton").click(function () {
  24. var method = document.getElementById("dateButton").value;
  25. });
  26. });
  27.  
  28. document.write(method);
  29.  
  30. $.ajax({
  31. url: 'time.php',
  32. data: JSON.stringify({data: 'json', jsonrpc: '2.0', method: method, id: 1}),
  33. type: 'post',
  34. success: function (result) {
  35. $(".wyniki").html(result);
  36. },
  37. error: function () {
  38. $(".wyniki").html("wystąpił błąd");
  39. }
  40. });
  41. }
  42.  
  43. </script>
  44. {/literal}
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement