Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>TimeJson</title>
- <meta charset="utf-8"/>
- <link rel="stylesheet" href="./jquery-ui-1.12.1.custom/jquery-ui.css">
- <script type="text/javascript" src="./jquery-ui-1.12.1.custom/external/jquery/jquery.js"></script>
- </head>
- <body>
- <button id="timeButton" onclick="timeAjax()" value='time'>Time</button>
- <button id="dateButton" onclick="timeAjax()" value='date'>Date</button>
- <div class="wyniki"></div>
- {literal}
- <script type="text/javascript" language="javascript">
- //Ajax
- function timeAjax() {
- var method ='';
- $(document).ready(function () {
- $("#timeButton").click(function () {
- method = document.getElementById("timeButton").value;
- });
- $("#dateButton").click(function () {
- method = document.getElementById("dateButton").value;
- });
- });
- document.write(method);
- $.ajax({
- url: 'time.php',
- data: JSON.stringify({data: 'json', jsonrpc: '2.0', method: method, id: 1}),
- type: 'post',
- success: function (result) {
- $(".wyniki").html(result);
- },
- error: function () {
- $(".wyniki").html("wystąpił błąd");
- }
- });
- }
- </script>
- {/literal}
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement