Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   разбор JSON (средствами библиотеки) (https://javascript.ru/forum/jquery/11208-razbor-json-sredstvami-biblioteki.html)

jekjuk 12.08.2010 18:45

разбор JSON (средствами библиотеки)
 
пытаюсь обработать массив пареметров из URL http://www.ringcentral.com/api/index...eResponse=json
*мне нужны страны /но не хватает навыка/
Код:

<html><head>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {

        $.getJSON(
                "http://www.ringcentral.com/api/index.php?cmd=getCountries&typeResponse=json", 
                function(data){   
                        $.each(data.result, function(){     
                                $("#test").text("<options>" + data.name + "</options>");
                        })
                }
        );
});
</script>
</head><body>
demo: 
<select id="test"></select>


</body></html>


Octane 12.08.2010 19:10

$(function () {
    $.getJSON(
        "http://www.ringcentral.com/api/index.php?cmd=getCountries&typeResponse=json",
        function (data) {
            var $test = $("#test");
            $.each(data.result, function(country) {
                $test.append("<option>" + country.name + "</option>"); 
            })
        }
    );
});


Часовой пояс GMT +3, время: 03:39.