【发布时间】:2012-02-17 04:29:37
【问题描述】:
如何使 mvc 控制器动作命中 ajax 转换器。我可以修改响应来触发它吗
$.ajaxSetup({
converters: {
"mytype1 mytype2": function (result) {
//do stuff
return newresult;
}
}
});
我曾尝试像这样更改 JsonResult 的内容类型和内容编码:
result.ContentType = "mytype1";
..
response.AppendHeader("Content-Encoding", "mytype1");
但没办法……
编辑:
我真正想要的是更改我的 mvc 操作的返回类型并添加一个 ajax 转换器(“mytype1 json”),并且仍然拥有所有期望 json 工作的现有 $.ajax 调用
【问题讨论】:
-
你从服务器 xml 返回什么? json?
-
到目前为止我只尝试过JsonResult..
标签: javascript jquery ajax model-view-controller converter