guys, i have a html page where onclick of a button a ajax request is sent to server , the request calls a jsp page which runs an oracle procedure.The procedure runs the logic and places it in a temp table . once procedure is completed , the values are returned to the client by selecting values from tmp table. as the response is too late . the data is not received at the client side.
伙计们,我有一个html页面,其中点击按钮ajax请求发送到服务器,请求调用一个运行oracle过程的jsp页面。该过程运行逻辑并将其放在临时表中。一旦过程完成,通过从tmp表中选择值将值返回给客户端。因为回应太晚了。客户端未收到数据。
solution: i tried to run the procedure in a separate thread using a ajax call. when the procedure is completed a global flag is set to indicate that the data is generated. if the response is 500 , a second ajax call invoked by timeout function after 10000 ms . the second call checks the global flag ,if true then reads from table and sends the response. if not again a timeout is set at the client side. this solution is not mature enough. , as the procedure may take long time to respond.
解决方案:我尝试使用ajax调用在单独的线程中运行该过程。当过程完成时,设置全局标志以指示生成数据。如果响应为500,则在10000毫秒后由超时功能调用第二个ajax调用。第二个调用检查全局标志,如果为true,则从表中读取并发送响应。如果没有再次在客户端设置超时。这个解决方案还不够成熟。 ,因为该程序可能需要很长时间才能作出回应。
please let me know a good solution for this problenm?
请让我知道这个问题的一个很好的解决方案?
1 个解决方案
#1
1
This is the classic "Quote Comparison Website" model.
这是经典的“报价比较网站”模型。
You need to make your requests more specific, like this...
您需要更具体地提出您的请求,例如......
First - you send the initial request for the long-running process using AJAX and you get back a "RequestId".
首先 - 您使用AJAX发送长时间运行进程的初始请求,然后返回“RequestId”。
Second - you call a "Check Status" service with your request id and receive a status. If you get "Working" you pause for a bit and re-check. If you get "Complete" you move onto the third stage.
其次 - 您使用您的请求ID调用“检查状态”服务并获得状态。如果你得到“工作”,你会暂停一下并重新检查。如果你得到“完整”,你就进入第三阶段。
Third - you call the "Get Results" service with your request id and instantly get the pre-prepared result back.
第三 - 您使用您的请求ID调用“获取结果”服务,并立即获得预先准备好的结果。
You will want to add a number of attempts into the second step - so if you've waiting for 10 minutes you give up and apologise to the user.
您需要在第二步中添加一些尝试 - 所以如果您等待10分钟,则放弃并向用户道歉。
#1
1
This is the classic "Quote Comparison Website" model.
这是经典的“报价比较网站”模型。
You need to make your requests more specific, like this...
您需要更具体地提出您的请求,例如......
First - you send the initial request for the long-running process using AJAX and you get back a "RequestId".
首先 - 您使用AJAX发送长时间运行进程的初始请求,然后返回“RequestId”。
Second - you call a "Check Status" service with your request id and receive a status. If you get "Working" you pause for a bit and re-check. If you get "Complete" you move onto the third stage.
其次 - 您使用您的请求ID调用“检查状态”服务并获得状态。如果你得到“工作”,你会暂停一下并重新检查。如果你得到“完整”,你就进入第三阶段。
Third - you call the "Get Results" service with your request id and instantly get the pre-prepared result back.
第三 - 您使用您的请求ID调用“获取结果”服务,并立即获得预先准备好的结果。
You will want to add a number of attempts into the second step - so if you've waiting for 10 minutes you give up and apologise to the user.
您需要在第二步中添加一些尝试 - 所以如果您等待10分钟,则放弃并向用户道歉。