![](/img/trans.png)
[英]How do I make the if/else statement get checked every time my function is called (JavaScript)?
[英]How do I get the browser to update before my next Javascript function is called?
我在從函數中獲取所需的功能時遇到了一些麻煩...基本上,我正在兩次調用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調用完成后才發生。 然后它永遠不會暢通...有什么想法嗎?
用另一種方法包裝您的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);
}
假設調用是async
-您可以將回調傳遞給ajax報告函數,還是可以使用其他函數或常量來設置回調? 否則,您將不得不輪詢響應-如何執行此操作將取決於$a_report
和/或其ajax功能背后的api返回的內容。
如果他們沒有async
則可能是錯字或其他東西。 如其他提示所示, $.blockUI;
應該可能是$.blockUI();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.