Call javascript from MVC controller action

后端 未结 9 1252
半阙折子戏
半阙折子戏 2021-02-01 07:04

Can I call javascript function from MVC controller action (not from view page) and get return value? How?


I need to make request to server

9条回答
  •  北海茫月
    2021-02-01 07:45

    There are ways you can mimic this by having your controller return a piece of data, which your view can then translate into a JavaScript call.

    We do something like this to allow people to use RESTful URLs to share their jquery-rendered workspace view.

    In our case we pass a list of components which need to be rendered and use Razor to translate these back into jquery calls.

提交回复
热议问题