I’m doing a rowcount with JSON and get an output like this in my php file json_data2.php:
{"limit": [{"rows":"127"}]}
Now I’m calling this file using a Javascript/Jquery function and try to get the rows back (127). I pretend to do it like this:
function limit(keyword){
$.getJSON("json_data2.php?l="+keyword,function(data)
{
$.each(data.limit,function(data){
var rows = data.rows;
return rows;
});
});
}
But every time I call the function in the Script I get “undefined”. Any pointers?
You need to fix your each statement. Added
thisto refer to data in question.http://jsfiddle.net/twGQh/