laimas,
это?
<script>
//именно такое и получит Ajax
$.getJSON("http://h116641.s08.test-hf.su/", function(data) {
$('.usddata').html(data.current.date);
$('.usddata2').html(data.previous.date);
//и вот тут данные этого объекта помещаются на свои места
$.each(data, function(k, o) {
$('.'+k).html("$ " + o.value + ' <b class=' + ['','down','up'][o.rate] +'>' + ['','▼','▲'][o.rate] +'</b>').attr("title", o.date)
})
});
</script>
или
<?
$currency = json_decode(file_get_contents('current.json'));
libxml_use_internal_errors();
if($xml = simplexml_load_file('http://www.cbr.ru/scripts/XML_daily.asp?date_req='.date('d/m/Y'))) {
$date = strtotime($xml->attributes()->Date);
if($date > strtotime($currency->current->date)) {
foreach ($xml->children() as $child) {
if($child->NumCode==840) {
$usd = round((float)str_replace(',', '.', $child->Value), 2);
break;
}
}
if($usd) {
if($rate = $usd - $currency->current->value) $rate = $rate < 0 ? 1 : 2;
$currency->previous = clone $currency->current;
$currency->current->date = date('j.n.Y', $date);
$currency->current->value = $usd;
$currency->current->rate = $rate;
$dir = dirname(__FILE__);
chdir($dir);
chmod($dir, 0777);
file_put_contents('current.json',json_encode($currency));
chmod($dir, 0700);
}
}
}
?>