Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

javascript - jQuery Ajax Post导致500内部服务器错误(JQuery Ajax Post results in 500 Internal Server Error)

I am trying to perform this AJAX post but for some reason I am getting a server 500 error.

(我正在尝试执行此AJAX帖子,但是由于某些原因,我遇到了服务器500错误。)

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");
    }
});

This is the string that should be returned:

(这是应该返回的字符串:)

{status:'200', text: 'Something'}
  ask by Nick translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

(使用Firefox / Firebug或IE8开发人员工具查看您从服务器获得的实际响应。)

If there has been an exception you'll get the YSOD html, which should help you figure out where to look.

(如果有异常,您将获得YSOD html,这应该可以帮助您确定要查找的位置。)

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.

(更好的是,如果不传递任何数据,则将其删除。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...