From fd2c28779925067e26a4e4e43e49f2f305a881e8 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Wed, 2 May 2018 14:17:29 +0200 Subject: [PATCH] Add support for JSONP RPC calls. --- rpc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rpc.php b/rpc.php index 2df358a..92660fd 100644 --- a/rpc.php +++ b/rpc.php @@ -33,4 +33,11 @@ if (array_key_exists('action', $_REQUEST)) { } header("Content-type: application/javascript"); -echo json_encode($response); + +if (isset($_GET['callback'])) { + // JSONP + echo $_GET['callback'] . '(' . json_encode($response) . ');'; +} else { + // JSON + echo json_encode($response); +}