I have a php-code, which can get json data from RPC server.
<?php
error_reporting(E_ALL);
$server = 'http://pogoda.ngs.ru/json/';
// API-method
$method = 'getForecast';
// input data
$params = array('name' => 'current',
        'city' => 'nsk');
// 
$request = array('method' => $method,
         'params' => $params);
// encode to json
$request = json_encode($request);
// 
$opts = array('http' => array('method'  => "POST",
                  'content' => $request)); 
// context stream
$context = stream_context_create($opts);
// get result
$result = file_get_contents($server, 0, $context);
$result = json_decode($result, true);
print_r($result);
?>
and then i try to do this in javascript by jquery. I found a lot of ways, but none of them has worked.
<html>
<head>
    <link rel=stylesheet type="text/css" href="myCssFile.css"> 
    <script type="text/javascript" src="jquery-1.11.0.min.js"></script>
</head>
<body>
<?php
header('Content-type: text/html; charset=utf-8');
?>
<script>
    var url = "http://pogoda.ngs.ru/json/";
    var request = {};
    request.method = "getForecast";
    request.params = {};
    request.params.name = "current";
    request.params.city = "nsk";
    request.params.jsonrpc = "2";
    request.params.dataType = "json";
    $.ajax({
    url: url,
    data: JSON.stringify(request),
    type: "POST",
    contentType: "application/json"
    }).done(function(rpcRes) {
    alert("ok");
    }).fail(function(err, status, thrown) {
    alert("Error ajax");
    });
</script>
</body>
</html>
I got errors or nothing all the time. Does anybody know something about it?
 
    