Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 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. var method ='';
  19. $(document).ready(function () {
  20. $("#timeButton").click(function () {
  21. method = document.getElementById("timeButton").value;
  22.  
  23. });
  24. $("#dateButton").click(function () {
  25. method = document.getElementById("dateButton").value;
  26.  
  27. });
  28. });
  29. document.write(method);
  30.  
  31.  
  32.  
  33. $.ajax({
  34. url: 'time.php',
  35. data: JSON.stringify({data: 'json', jsonrpc: '2.0', method: method, id: 1}),
  36. type: 'post',
  37. success: function (result) {
  38. $(".wyniki").html(result);
  39. },
  40. error: function () {
  41. $(".wyniki").html("wystąpił błąd");
  42. }
  43. });
  44. }
  45.  
  46. </script>
  47. {/literal}
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement