在MVC应用程序中调用Javascript [英] Call Javascript in MVC Application

查看:100
本文介绍了在MVC应用程序中调用Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从MVC中的Controllers文件调用javascript函数

how to call javascript function from Controllers file in MVC

推荐答案

我想,不可能从controllers类调用javascript.

完全相同的问题在这里提出: http://stackoverflow. com/questions/4284618/how-to-call-javascript-function-from-controllers-file-in-mvc [ http://stackoverflow.com/questions/2709978/call-javascript-from-mvc-控制器操作 [ ^ ]
I guess, calling javascript from controllers class is not possible.

Exact same question asked here: http://stackoverflow.com/questions/4284618/how-to-call-javascript-function-from-controllers-file-in-mvc[^]

Have a look at more discussion of above thread here confirming it cannot be done:
http://stackoverflow.com/questions/2709978/call-javascript-from-mvc-controller-action[^]


有一种方法可以从控制器调用javascript函数.不是直接而是通过查看.

只需将javascript函数的名称传递给使用模型从控制器进行查看,然后就可以使用document.ready提供jquery从视图进行调用.


HTH
There is one way you can call javascript function from controller. Not directly but going through view.

Just pass the name of your javascript function to view from controller using model and then you can call it from view using document.ready provision of jquery.


HTH


这篇关于在MVC应用程序中调用Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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