M
M
Mukaev2014-06-23 03:34:38
JavaScript
Mukaev, 2014-06-23 03:34:38

How to display number (price) from json string?

....

<script>
       WuBook.fount({'dfrom': '21/07/2014', 'dto': '23/07/2014'}, function(data) {console.log(data)});
</script>

We get in the console {"warnings": [], "results": {"1366977020": {"1": 4600.0, "2": 5300.0}}, "error": ""}
where 4600 and 5300 is the price
Tell me how display just a number (price) on the html page

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey, 2014-06-23
@rdifb0

for (key in data.results) {
    if (data.results.hasOwnProperty(key)) {
        var el = data.results[key];
        console.log(el[1], el[2]);
        break;
    }
}

1
1001001 111, 2014-06-23
@IgorO2

alert(data.results['1366977020']['1']);
alert(data.results['1366977020']['2']);

D
Denis Ineshin, 2014-06-23
@IonDen

Instead of console.log(data) write for example the code:

var obj = JSON.parese(data);
$("body").html(obj.results["1366977020"]["1"]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question