Ajax回发未调用javascript函数

编程入门 行业动态 更新时间:2024-10-11 21:26:13
本文介绍了Ajax回发未调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在页面上加载成功调用的javascript函数,但是当使用ajax进行页面回发时,javascript不再被调用.

On page load the javascript functions called successfully, but when the page postback with the ajax the javascript didn''t called again. Thanks!

推荐答案

AJAX调用返回时,它不会导致页面加载事件触发,因为发生的一切是在后台检索了一些信息,并且页面的一部分已更新,这不是页面重新加载. 如果您希望在AJAX调用完成后再次调用javascript函数,则需要通过直接调用或使用setTimeout [ ^ ]函数可稍微延迟调用,这是一个更好的选择. When an AJAX call returns it does not cause the page load event to fire as all that is happening is that some information has been retrieved in the background and a part of the page is updated this is not a page reload. If you want the javascript function to be called again once the AJAX call has completed you need to put a call to the original javascript function in the function that handles the javascript response either through a direct call or use the setTimeout[^] function to delay the call slightly which is a better option.

您需要在调用后显式调用Javascript函数. 为此,如果要从JS函数启动Ajax调用,则需要在从服务器收到响应后再调用函数. 或 如果您使用的是Updatepanel,则可以将功能注册为启动脚本块,如 You need to call the Javascript function explicitely, after the call. For that if you are initiating Ajax call from JS function, the you need to call your function after recieving the response from server. Or If you are using Updatepanel, the you can register your function as startupscript block as ScriptManager.RegisterStartupScript(this.Page, typeof(System.Web.UI.Page), "StartupScript", "<script type=''text/javascript'' language=''javascript''>javascript:yourfunction()</script>", false);

更多推荐

Ajax回发未调用javascript函数

本文发布于:2023-11-27 22:22:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639829.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   Ajax   回发未   javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!