从WebMethod调用Jquery函数 [英] Call Jquery Function from WebMethod
本文介绍了从WebMethod调用Jquery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我试图通过下面的线路从Codebehind Webmethod调用Jquery函数但是我无法调用它
hello,
I am trying to call Jquery Function from a Codebehind Webmethod by below line but i am not able to call it
ScriptManager.RegisterStartUpScriptBlock(this,this.gettype(),"myfun","myFunction()",true)
推荐答案
我打算回答这个问题,但发现 F-ES Sitecore 添加了一个很棒的评论,这实际上就是答案。
WebMethods
用于获取一些输入并返回结果。你不应该从那启动客户端脚本,为什么?您已经在客户端脚本上执行操作,当您从WebMethod
获得结果时,则在 AjaxSuccess
方法,执行你想要的任何 JavaScript 代码。这将非常容易。
I was going to answer this, but found F-ES Sitecore has added an awesome comment, which is actually the answer.
WebMethods
are meant to take some input and return the result. You should not initiate a client script from that and why to? You are already doing operations on client scripts and when you get the result from theWebMethod
, then inside the AjaxSuccess
method, execute whatever JavaScript Code you want to. That will be very easy.
这篇关于从WebMethod调用Jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文