Hi I have a web service which returns data in json format. I am not able to bind the country names and the country code returned from web service. My code is
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<title>Using jQuery and XML to populate a drop-down box demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $.ajax({
            type: "get",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify({"objectData": formData}),
            url: "127.0.0.1:15021/Service1.svc/getallcustomers",
            dataType: "json",
            success: ajaxSucceess,
            error: function(xhr, ajaxOptions, thrownError) {
                alert(xhr.status);
                alert(xhr.responseText);
                alert(thrownError);
            }
            //error: ajaxError
        });
        function ajaxSucceess(response) {
            $.each(response.d, function(key, value) {
                $("#ddlCountry").append($("<option>       </option>").val(value.country_code).html(value.country_name));
            });
        }
        function ajaxError(response) {
            alert(response.status + ' ' + response.statusText);
        }
    });
</script>
my html code is
<body> 
    <div>
        <select id="ddlCountry"> 
            <option value="-1">loading</option> 
        </select>
    </div>
</body>
</html>
sample json data returned from web services
// correct json format
{
    "GetAllCustomersResult": [
        {
            "country_code": "OT",
            "country_desc": "Other",
            "country_name": "Other",
            "country_sk": "-1",
            "country_telecom_code": "+1",
            "currency_sk": 225,
            "date_format": "mdy",
            "distance_measurement_unit": null,
            "fnb_type_sk": "",
            "is_sms_notification": null
        },
        {
            "country_code": "ZW",
            "country_desc": null,
            "country_name": "Zimbabwe",
            "country_sk": 239,
            "country_telecom_code": "263",
            "currency_sk": 11,
            "date_format": null,
            "distance_measurement_unit": null,
            "fnb_type_sk": "",
            "is_sms_notification": null
        }
    ]
}
 
     
     
     
     
    