2012-11-18, 20:05
Hi there,
I've been trying to follow the working code in this thread http://forum.xbmc.org/showthread.php?tid=140310 but sadly with no success.
I'm completely new to JSON-RPC and haven't written much javascript either, but as I've been able to get responses playing around in C# and Python, I'm convinced the flaw lies somewhere in my Javascript, even through it's basically lifted directly from the above thread.
The other thing that's confusing me is that running the debug log on my xbmc server shows no JSON requests at all, not even failed ones. These requests definitely do show up when I send them from other sources
From what I've read, I think the following basic web-page should enable me to call the JSONRPC.Introspect method, and then the response should pop up in a window alert (Yes, I'm really falling at the first hurdle).
Any help at all would be tremendously appreciated.
I've been trying to follow the working code in this thread http://forum.xbmc.org/showthread.php?tid=140310 but sadly with no success.
I'm completely new to JSON-RPC and haven't written much javascript either, but as I've been able to get responses playing around in C# and Python, I'm convinced the flaw lies somewhere in my Javascript, even through it's basically lifted directly from the above thread.
The other thing that's confusing me is that running the debug log on my xbmc server shows no JSON requests at all, not even failed ones. These requests definitely do show up when I send them from other sources
From what I've read, I think the following basic web-page should enable me to call the JSONRPC.Introspect method, and then the response should pop up in a window alert (Yes, I'm really falling at the first hurdle).
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
</head>
<body>
<script>
function thecallback(a, b, c) {
alert(a);
}
function xbmcjson(){
var params = '{"jsonrpc": "2.0", "method": "JSONRPC.Introspect", "id": "1"}';
$.ajax({
type: 'POST',
url: 'http://192.168.0.10:9080/jsonrpc',
data: params,
success: thecallback(result, textStatus, XMLHttpRequest),
dataType: 'json',
contentType: 'application/json'
});
}
</script>
<button onclick="xbmcjson()">Try it</button>
</body>
</html>
Any help at all would be tremendously appreciated.