Problem using $.each() on json containing "length" key
When trying to iterate over data using jquery's each() function, if my json contains a key named "length", I don't get any results.
This json works:
echo '{"title":"test","lengths":"3"}';
This doesn't:
echo '{"title":"test","length":"3"}';
I'm using jquery and jquery ui. Anyone know how to avoid this problem? Here is my code:
- $.ajax({
url: "http://example.com/page.php",
type: "GET",
dataType: "json",
success: function(json){
alert('in');
str = '';
$.each(json, function(key, value) {
str += key + " : <strong>" + value + "</strong><br/>";
});
$("#data").html(str);
$( "#dialog" ).dialog();
}
});