如何将从HTML.Action返回的结果保存到变量并显示在div中 [英] how to save the result returned from the HTML.Action to variable and display inside the div

查看:138
本文介绍了如何将从HTML.Action返回的结果保存到变量并显示在div中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

众所周知 @ Html.Action 返回MvcHtmlString,因此可以将结果保存在变量中。 />


我试过以下

Hi friends,
As you all know the @Html.Action returns MvcHtmlString, so can save the result in a variable.

I tried following

<script type="text/javascript">
        @{
            var strHTML = @Html.Action("About", "Home");
        }

        alert("@strHTML");

        $('#divAbout').html(@strHTML);
</script>





我的上述代码无法正常工作,警报既不正常也没有显示在divAbout。



知道怎么做。



提前致谢



My above code is not working, neither the alert is working nor it is displayed inside the divAbout.

Any idea how to do the same.

Thanks in advance

推荐答案

('#divAbout')。html(@strHTML);
< / script>
('#divAbout').html(@strHTML); </script>





我的上述代码无法正常工作,警报既不正常也没有显示在divAbout。



知道怎么做。



提前致谢



My above code is not working, neither the alert is working nor it is displayed inside the divAbout.

Any idea how to do the same.

Thanks in advance


这篇关于如何将从HTML.Action返回的结果保存到变量并显示在div中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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