Hi, i have a problem with the jquery each method.
My Object
first_obj = {};
first_obj[11] = new Array('http://blub.de', 'hsdfe', 'hsdfe' );
first_obj[54] = new Array('http://blub.de', 'sdfe', 'hsdfde' );
first_obj[99] = new Array('http://blub.de', 'sdf', 'sdfde' );
Get Results and insert it into the object "second_obj_results"
second_obj_results = {};
$.each(first_obj, function(i, val)
{
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("feed");
for (var i = 0; i < result.feed.entries.length; i++)
{
second_obj_results[id] = new Array(''+rsd+'', ''+rtitle+'', ''+fege+'' ); // Create new obj with the results
}
}
)};
read_new_obj();
and here is my problem
When i say read_new_obj();
... // dont work
and when i say setTimeout('read_new_obj();',2000);
... // it works
Read the new obj
function read_new_obj()
{
$.each(second_obj_results, function(i, val)
{
// do something
});
}
I think the problem is that the "Get Results" is not finished. But the solution with the Timeout is very bad. It is possible that the "Get Results" need more time than 2 seconds.
How can i say, if "each first_object" ready -> Start the function "read_new_obj" ?
Thanks in advance! Peter
PS: Sorry for my bad english :(