English 中文(简体)
未调出正确顺序/ 同步方法的方法
原标题:Method not called in correct order / asyncronous method

我在试图按此顺序装入这些函数时遇到一个问题:顺便说一下,我使用数据表格和jQuery(我敢肯定你们中许多人已经知道这一点)。

currPage=LookupPts.ots.oTable.fnloadAjax (); LookupPts.ts.oTable.fnloadAjax(); LookupPts.o.fnPageChange(crPage.iPage);

之后,我试图立即运行 ,我的问题是如何在 < a/n > ax/read > trad > a.

最佳回答

您需要执行回调, 因为 Javascript 是非阻塞语言, 不按步执行命令 。 因此您需要回调, 在方法完成后再回调 。

我刚刚查看了ReloadAjax方法的定义(我从未使用过这个方法 ) 。 如果我有正确的定义: 函数( osettings, sNewSource, fnCallback, bStandingRedraw ), 以下代码应该有效 :

currPage = LookupPts.oTable.fnPagingInfo();
LookupPts.oTable.fnReloadAjax(null, null, function(){
   LookupPts.oTable.fnPageChange(currPage.iPage);
});
问题回答

好吧,我把它修好了。

在我公布我的问题之前,我尝试了与你们大家描述的相同的方法,但我仍然有同样的问题。由于某种原因,这行不通。

我做了什么才能修好它?

在调试插件后我发现,参数顺序不正确。插件的参数是: oSetting, s NewSource, bStandingRedraw, fnCallback 。

当这个方法被命名为我的论点不正确的顺序时, 我注意到了。 我的命令是 oSettings = object, n nNewSource = null, fnCallback = null, bStandingRedraw = 函数 。

诀窍是将参数按正确的顺序排列,在参数列表中,回调为第二:

                        currPage = LookupPts.oTable.fnPagingInfo();
                        LookupPts.oTable.fnReloadAjax(null, function(){
                           LookupPts.oTable.fnPageChange(currPage.iPage);
                           console.log("finished loading the page details");
                        }, null);

I got confused with the first parameter oSettings. By the way how does the first parameter get loaded with the object? Thanks everyone!

查看 < a href=> http://databables.net/explet-ins/api" rel=“nofollow” > plutin 文档 fnloadAjax () 有此签名:

fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw ) { }

因此,您可以在 AJAX 调用完成后通过调回函数作为第三个参数执行。请试此 :

currPage = LookupPts.oTable.fnPagingInfo();
LookupPts.oTable.fnReloadAjax(null, null, function() { 
    LookupPts.oTable.fnPageChange(currPage.iPage);
});

尝试此 :

currPage = LookupPts.oTable.fnPagingInfo();
LookupPts.oTable.fnReloadAjax(null, null, function() {
    LookupPts.oTable.fnPageChange(currPage.iPage);
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.