jQuery加载方法不适用于.cshtml扩展名 [英] Jquery load method not working with .cshtml extension
本文介绍了jQuery加载方法不适用于.cshtml扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我必须将cshtml页面插入包含id = main的div中.我使用了jquery加载方法来添加cshtml页面,但无法正常工作...
示例代码:
$(#main1").load(''sample.cshtml'');
任何机构都可以帮助我,先谢谢
Hi all,
i have to insert the cshtml page in to the div containing id=main. I used jquery load method to add the cshtml page but not working...
sample code:
$("#main1").load(''sample.cshtml'');
Any body help me thanks in advance
推荐答案
(#main1").load(''sample.cshtml'');
任何机构都可以帮助我,谢谢
("#main1").load(''sample.cshtml'');
Any body help me thanks in advance
.cshtml是mvc 3剃须刀的特定页面.它不能像html页面一样提供.因此,从jquery中,如果从"Home
"控制器呈现"sample
"视图,则必须使用"/home/sample
",而不仅仅是"sample.cshtml
".
例如,考虑以下控制器:
.cshtml is a mvc 3 razor specific page. It cannot just be served like an html page. So from jquery, if your "sample
" view is rendered from "Home
" controller, you will have to use "/home/sample
" and not just "sample.cshtml
".
For example, consider the following controller:
public class HomeController : Controller
{
public ActionResult sample()
{
return View();
}
}
默认情况下,示例操作方法将返回名为"sample.cshtml
"的视图.因此,要获取此页面的内容,请使用/home/sample
.
希望这会有所帮助!
The sample action method would return a view named "sample.cshtml
" by default. So in order to get the contents of this page use /home/sample
.
Hope this helps!
这篇关于jQuery加载方法不适用于.cshtml扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文