asp.net - jQuery--result length -
i'm using asp.net , jquery cascading dropdown. i'm getting values not getting bind. result of json
giving length total chars not total records
the result
{ "table": [ { "voyagemasterid": 3, "voyagecode": "9101" }, { "voyagemasterid": 7, "voyagecode": "1617" } ] }
but giving length 93
but here total records 2
hence when bind values dropdown not getting bind.
my json :
$.ajax({ type: "post", contenttype: "application/json; charset=utf-8", url: "port.aspx/code_get", data: "{serviceid:'" + $(".ddlservice").val() + "'}", datatype: "json", success: function (data) { try { success(data.d); // function success(result) { $(".ddlvoyage").empty(); $(".ddlvoyage").append("<option value=''>select </option>"); $.each(result, function (index, value) { $(".ddlvoyage").append("<option value='" + value.voyagemasterid + "'>" + value.voyagecode + "</option>"); }); }
iam not getting data bind select , data json not giving proper result.
can 1 please help
i'm guessing data
coming string service, rather actual json object.
try array length:
var json = $.parsejson(data.d); console.log(json.length);