2010-02-02 74 views
0

我從我的函數中獲得所需的功能有點麻煩...基本上,我做了兩個調用AJAX函數(由Oracle APEX提供,所以我不能改變這些),但他們需要一段時間。我想在動作正在進行時顯示標準的AJAXy旋轉GIF,但我沒有太多的運氣。這是我到目前爲止有:在我的下一個Javascript函數被調用之前,如何讓瀏覽器更新?

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; 
} 

我目前遇到的具體問題是,用戶界面的阻塞似乎一旦Ajax調用完成後只發生。那麼它永遠不會阻止......任何想法?

回答

2

環繞你阿賈克斯的另一種方法,用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); 
} 
+0

完美延緩這種方法!謝謝! – 2010-02-02 17:08:32

0

假設呼叫爲async - 您可以將回調傳遞給ajax報告函數,還是使用其他函數或常量設置回調?否則,你必須輪詢響應 - 你將如何做,這取決於從$a_report和/或ajax功能背後的api返回什麼。

如果他們不是async那麼它可能是一個錯字或什麼的。至於其他的海報建議$.blockUI;大概應該是$.blockUI();

相關問題