I used this jquery each function and iterated my json data with it….
$.each(data.Results, function() {
divs += '<div class="resultsdiv"><br />
<span style="display: inline-block;width:150px;" class="resultName">'
+ this.Mat_Name + '</span><span class="resultfields" style="padding-left:10px;">
Measurement :</span> <span class="resultfieldvalues">'
+ this.Mes_Name + '</span> <a href="/Materials/Delete/' + this.Id + '">
Delete</a> <a href="/Materials/Details/' + this.Id + '">Details</a>
<a href="/Materials/Edit/' + this.Id + '">Edit</a></div>';
});
alert(divs.length); doesnt seem to get the count…. Any suggestion…
divsis a string, sodivs.lengthwould return the length of that string. You need to convert it into a DOM node, select the divs, and get the count:Alternatively, in the code you provided you could just get the length of the data.Results array: