Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何通过Javascipt回调处理耗时的webservice操作_Javascript_Asp.net_Ajax_Web Services - Fatal编程技术网

Javascript 如何通过Javascipt回调处理耗时的webservice操作

Javascript 如何通过Javascipt回调处理耗时的webservice操作,javascript,asp.net,ajax,web-services,Javascript,Asp.net,Ajax,Web Services,我在我的一个Web应用程序中执行了以下操作。我有一个返回值的函数。此值应传递给单独运行到我的web应用程序的web服务方法。此web服务操作需要一些时间才能完成,因此必须在后台运行,完成后应返回消息。我想通过Javascript回调实现这一点。代码的基本流程如下: Dim shr_intfB_Common_LCI As clsCreamsCommon Dim stringResult As StringResult shr_intfB_Common_LCI = New clsCreamsC

我在我的一个Web应用程序中执行了以下操作。我有一个返回值的函数。此值应传递给单独运行到我的web应用程序的web服务方法。此web服务操作需要一些时间才能完成,因此必须在后台运行,完成后应返回消息。我想通过Javascript回调实现这一点。代码的基本流程如下:

 Dim shr_intfB_Common_LCI As clsCreamsCommon
 Dim stringResult As StringResult
 shr_intfB_Common_LCI = New clsCreamsCommon
 Call shr_intfB_Common_LCI.CreamsBooking(clsTapsCreamsPropsDtl,
                               intRetCode, strMessage, intRequestId
                               )

// This intRequestId needs to be passed to the following web service.
Do
   Threading.Thread.Sleep(10 * 1000) '10 Second
   stringResult = objService.CheckRequestStatus(objServiceUser, intRequestId)
   Loop Until stringResult Is Nothing Or stringResult.ReturnCode <> 2    

//The stringResult includes the followings which I have to display. 
MessageBox(Me, stringResult.ReturnCode, stringResult.ReturnData + stringResult.ReturnMessage)
Dim shr\u intfB\u Common\u LCI作为clsCreamsCommon
将stringResult暗显为stringResult
shr\u intfB\u Common\u LCI=新的CLSChrysCommon
致电shr_intfB_Common_LCI.CreamsBooking(clsTapsCreamsPropsDtl,
intRetCode、strMessage、intRequestId
)
//需要将此intRequestId传递给以下web服务。
做
线程。线程。睡眠(10*1000)'10秒
stringResult=objService.CheckRequestStatus(objServiceUser,intRequestId)
循环直到stringResult为Nothing或stringResult.ReturnCode 2
//stringResult包括我必须显示的以下内容。
MessageBox(Me、stringResult.ReturnCode、stringResult.ReturnData+stringResult.ReturnMessage)

我不想使用线程或任务,因为这是一个web应用程序,而是使用JavaScript回调。请在这方面帮助我。

要在JavaScript中建立回调函数,可以使用jQuery ajax或PageMethods调用

这两个选项将分别运行,一旦web方法完成执行,将返回成功或失败回调

JavaScript中的页面方法