JQuery的阿贾克斯后导致500内部服务器错误 [英] JQuery Ajax Post results in 500 Internal Server Error

查看:147
本文介绍了JQuery的阿贾克斯后导致500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行这个AJAX的职位,但由于某种原因,我得到一个服务器的500错误。我可以看到它打在控制器突破点。所以,问题似乎是在回调。有人吗?

I am trying to perform this AJAX post but for some reason I am getting a server 500 error. I can see it hit break points in the controller. So the problem seems to be on the callback. Anyone?

谢谢!

$.ajax({
type: "POST",
    url: "InlineNotes/Note.ashx?id=" + noteid,
    data: "{}",
    dataType: "json",

    success: function(data) {
        alert(data[1]);
    },
    error: function(data){
    alert("fail");

    }

});

这是应返回的字符串:

{状态:200的文字:'东西'}

{status:'200', text: 'Something'}

推荐答案

我怀疑它通过断点后,服务器的方法抛出异常。使用Firefox / Firebug的或IE8的开发者工具来看看你是从服务器获取的实际响应。如果出现了异常,你会得到YSOD HTML,这应该帮助你找出去哪里找。

I suspect that the server method is throwing an exception after it passes your breakpoint. Use Firefox/Firebug or the IE8 developer tools to look at the actual response you are getting from the server. If there has been an exception you'll get the YSOD html, which should help you figure out where to look.

还有一件事 - 你的数据属性应该是{}不是{},前者是一个空对象,而后者是一个字符串,它是无效的,因为一个查询参数。更妙的是,就这么走了,如果你没有传递任何数据。

One more thing -- your data property should be {} not "{}", the former is an empty object while the latter is a string that is invalid as a query parameter. Better yet, just leave it out if you aren't passing any data.

这篇关于JQuery的阿贾克斯后导致500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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