Jquery-在每个都准备就绪时启动函数

Jquery-在每个都准备就绪时启动函数,jquery,each,Jquery,Each,我对jquery的每个方法都有一个问题 我的对象 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' ); 获取结果并将其插入对象“第二个

我对jquery的每个方法都有一个问题

我的对象

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' ); 
获取结果并将其插入对象“第二个对象结果”

我认为问题在于“获取结果”尚未完成。但是超时的解决方案非常糟糕。“获取结果”可能需要超过2秒的时间

如果“每个第一个对象”准备就绪->启动函数“read\u new\u obj”,我怎么说

提前谢谢! 彼得


PS:很抱歉我的英语不好:(

它看起来像
feed.load()
使用回调函数作为参数。我猜这个回调函数是在数据到达时触发的?
如果是这种情况,请将您的
read\u new\u obj()
方法直接放入该回调中

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+'' );
      }
      read_new_obj();
    }
)};
feed.load(函数(结果){
如果(!result.error){
var container=document.getElementById(“提要”);
对于(变量i=0;i

我不太了解
google ajax api
,但我非常确定
.load()
将启动一个
异步请求
。因此您的
read\u new\u obj()
是在
.load()函数完成之前执行的。

我明白了。-->google.setOnLoadCallback()@Peter:这应该是你想要的结果。你在
first_obj
上循环,它包含三个入口。好吧,但看起来你没有使用这些信息,非常混乱。我希望你使用
first_obj
数组中的第一个入口来访问该url。
function read_new_obj()
{

    $.each(second_obj_results, function(i, val)
    {   


    // do something

    });


}       
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+'' );
      }
      read_new_obj();
    }
)};