I'm trying to bind a drop down using .json file.
My ActionMethod:
public JsonResult LoadDropdown()
{
using (StreamReader sr = new StreamReader(Server.MapPath("~/Scripts/Drop1.json")))
{
var users = JsonConvert.DeserializeObject<List<Item>>(sr.ReadToEnd());
return Json(users, JsonRequestBehavior.AllowGet);
}
}
My AJAX:
$.ajax({
type: "GET",
url: "/Home/LoadDropdown",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var ddlCustomers = $("[id*=drop1]");
ddlCustomers.empty().append('<option selected="selected" value="0">--Please select--</option>');
//alert(data.d);
$.each(data.d, function () {
ddlCustomers.append($("<option></option>").val(this['id']).html(this['name']));
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert(textStatus + "_" + errorThrown);
}
});
My action method returns the following JSON Objects,
Now in Ajax I'm getting 'Undefined' when I checked 'data.d' before loop. Also 'data' holding objects like - [object]. Can anyone please help me what is the mistake?

$.each(data, function (index, item) { ddlCustomers.append($("<option></option>").val(item.id).text(...data.dcame?