简体   繁体   English

在c#mvc操作中返回Javascript将视图替换为纯文本

[英]Return Javascript in c# mvc action replaces view with plain text

My code which was working earlier with a Action returning Javascript has suddenly stopped working. 我之前使用Action返回Javascript的代码突然停止了工作。

My view shows a jquery dialog and within that dialog when user clicks save button control goes to mvc post which returns 我的视图显示了一个jquery对话框,并且在该对话框中,当用户单击“保存”按钮时,控件将转到mvc post并返回

 return JavaScript("OnCreateSuccess('some value')");

Earlier the javascript method use to execute.. now instead, the browser view is replaced with text 之前使用javascript方法执行。现在,浏览器视图已替换为文本

OnCreateSuccess('some value'); OnCreateSuccess('一些值');

I know its not the good way of passing information but I inherited this code like it is. 我知道这不是传递信息的好方法,但是我照原样继承了此代码。

I rewrote the Action to return JSON and used Ajax call and jquery callback to handle the returned values. 我重写了Action以返回JSON,并使用Ajax调用和jquery回调来处理返回的值。

Thanks @Deep 谢谢@Deep

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM