问题重定向到另一个html页面(重定向取消之前执行该功能) [英] Problems redirect to another html page (redirect cancels the execution of the function before it)

查看:351
本文介绍了问题重定向到另一个html页面(重定向取消之前执行该功能)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码



I have the code below

GetListTourneeByPersonnelIDFromServer();
window.location = './Calendrier.html';





当我执行此代码时有了,重定向到Calendar页面取消了GetListTourneeByPersonnelIDFromServer函数的执行,因为我不能使用术语CallBack,因为在GetListTourneeByPersonnelIDFromServer函数调用它时,还有更多的包含循环的函数,如何解决这个问题和thanx



When I execute this code there is, the redirection to the Calendar page cancels the execution of the GetListTourneeByPersonnelIDFromServer function, and since I can not use the term CallBack, because in GetListTourneeByPersonnelIDFromServer function called it there's more to another function that contains loops, how to resolved this problem and thanx

推荐答案



Hi,
add the window.location.href="page.html" at end of the function GetListTourneeByPersonnelIDFromServer()





作为javascript函数调用是一个同步所以它立即进入下一行代码。在完成功能执行之前,它会重定向到下一页。

这可以解决问题。



--Avinash



As javascript function calls are asynchronous so it immediately going to next line of code. And before completing function execution it is redirecting to next page.
May this will solve the issue.

--Avinash


这篇关于问题重定向到另一个html页面(重定向取消之前执行该功能)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆