EmptyResult 上的 jQuery AJAX 请求炸弹
这是类似于这个问题但是这个没有解决我的问题,因为这正是我处理这个问题的方式。
$("#code").live("change", function() {
var data = { codeId: $(this).find(":selected").attr("id") };
$.ajax({
type: "GET",
url: codeUrl,
data: data,
success: function(html) {
// never gets hit if EmptyResult();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
// never gets hit until page navigation, which aborts this call
}
});
});
[HttpGet]
public ActionResult CodeParameters(int codeId)
{
IList<AdjustmentParameter> parameters = GetCodeParameters(codeId);
if (parameters == null || !parameters.Any())
return new EmptyResult();
return PartialView("EditorTemplates/AdjustmentParameters", parameters);
}
任何返回 HTML 的代码都会按预期工作,但任何返回 new EmptyResult()
的代码似乎会破坏 ajax 调用。我应该做一些不同的事情吗?奇怪的是,这不会发生在 3 个不同的 Web 服务器上,只会发生在面向公众的服务器上(自然)。
This is similar to this question but this did not solve my problem since this is exactly how I'm handling this.
$("#code").live("change", function() {
var data = { codeId: $(this).find(":selected").attr("id") };
$.ajax({
type: "GET",
url: codeUrl,
data: data,
success: function(html) {
// never gets hit if EmptyResult();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
// never gets hit until page navigation, which aborts this call
}
});
});
[HttpGet]
public ActionResult CodeParameters(int codeId)
{
IList<AdjustmentParameter> parameters = GetCodeParameters(codeId);
if (parameters == null || !parameters.Any())
return new EmptyResult();
return PartialView("EditorTemplates/AdjustmentParameters", parameters);
}
Any code that returns HTML works as expected but any code that returns new EmptyResult()
seems to break the ajax call. Should I be doing something differently? Strangely enough this does not happen on 3 different web servers, only on the public facing server (naturally).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 Fire Fox 中遇到了一个 EmptyResult 的问题。当我在 ajax 选项中指定
dataType: 'html'
时已修复。I ran into an issue in Fire Fox with an EmptyResult. Fixed when I specified the
dataType: 'html'
in the ajax options.