PHP Classes

File: examples/exampleViAjax.html

Recommend this page to a friend!
  Classes of Chris Jeffries   PHP JSON RPC 2.0 Server   examples/exampleViAjax.html   Download  
File: examples/exampleViAjax.html
Role: Example script
Content type: text/plain
Description: HTML page to test using the AJAXclient
Class: PHP JSON RPC 2.0 Server
Handle to HTTP requests in JSON RPC v2.0 format
Author: By
Last change:
Date: 5 years ago
Size: 1,146 bytes


Class file image Download
        <title>JSON-RPC Tester via Ajax</title>
        <script src='jsonrpcClient.js'></script>
            window.addEventListener('load', function () {
                let btn = document.getElementById('btn');
                let txt = document.getElementById('txt');
                try {
                    btn.addEventListener('click', function (e) {
                        let request = JSON.parse(txt.value);
                        let p = jsonrpcClient('../index.php',, request.method, request.params);
                        p.then(function (response) {
                            alert('ALL OK: ' + JSON.stringify(response, undefined, 4));
                        p.catch(function(response) {
                            alert('OH NO!: ' + JSON.stringify(response, undefined, 4));
                catch (e) {
        <h1>JSON-RPC Tester via Ajax</h1>
        <p>This tester fires off a JSON-RPC request to the server using
        a Javascript Ajax client in the file 'jsonrpc.js'</p>
        <textarea id=txt cols=50 rows=10>{
        <br />
        <button type=button id=btn>Send!</buttpn>