转载:
http://www.cnblogs.com/jiagoushi/archive/2013/01/24/2875454.html
http://www.cnblogs.com/lvcha/archive/2010/05/08/1730490.html
例子:
JavaScriptResult的使用方法
html(../Home/Index.cshtml)
<body>
<button class="Btn">按钮</button>
</body>
js
$(document).ready(function () {
$(".Btn").click(function () {
$.ajax({
type: "POST",
url: "../Home/Index",
data: {},
contentType: "application/x-javascript;charset=UTF-8",
dataType: "script",
success: function () { },
error: function () {
alert("出错了");
}
});
});
});
HomeController
public JavaScriptResult Index()
{
return JavaScript("alert('dsdsds')");
}