0

我在从我的函数中获取所需的功能时遇到了一些麻烦......基本上,我正在对 AJAX 函数进行两次调用(由 Oracle APEX 提供,所以我无法更改这些)但他们正在采取尽管。我想在动作进行时显示标准的 AJAXy 旋转 gif,但我运气不佳。这是我到目前为止所拥有的:

function paginate(reportIDs, startRecord)
{
 //block access to the UI and show a "please wait" message
  $.blockUI({ css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
        } });

  //make the two AJAX calls to the APEX provided function
  for(var i = 0;i<reportIDs.length;i++)
  {
    $a_report(reportIDs[i], startRecord, ITEMS_PER_PAGE, ITEMS_PER_PAGE);
  }

  //clean up some APEX garbage on the page
  formatPage();

  //make the "please wait" message go away
  $.unblockUI;
}

我目前遇到的具体问题是 UI 的阻塞似乎只有在 AJAX 调用完成后才会发生。然后它永远不会解锁......有什么想法吗?

4

2 回答 2

2

将您的 ajax 包装在另一种方法中,并将该方法延迟 1 毫秒

function paginate(reportIDs, startRecord)
{
    //block access to the UI and show a "please wait" message
    $.blockUI({ css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
        }
    });
    setTimeout(function(){
        //make the two AJAX calls to the APEX provided function
        for(var i = 0;i<reportIDs.length;i++)
        {
            $a_report(reportIDs[i], startRecord, ITEMS_PER_PAGE, ITEMS_PER_PAGE);
        }

        //clean up some APEX garbage on the page
        formatPage();

        //make the "please wait" message go away
        $.unblockUI();
   }, 1);
}
于 2010-02-02T16:39:22.577 回答
0

假设调用是async- 您可以将回调传递给 ajax 报告函数或使用另一个函数或常量来设置回调吗?否则,您将不得不轮询响应 - 您将如何做到这一点将取决于从返回的内容$a_report和/或它们的 ajax 功能背后的 api。

如果他们不是async那么它可能是一个错字或什么的。正如另一张海报所暗示的那样$.blockUI;,可能应该是$.blockUI();

于 2010-02-02T16:29:32.307 回答