Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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'} 
like image 528
Nick Avatar asked Aug 28 '09 20:08

Nick


People also ask

Why do I get 500 internal server error?

The 500 Internal Server error could be caused by an error during the execution of any policy within Edge or by an error on the target/backend server. The HTTP status code 500 is a generic error response. It means that the server encountered an unexpected condition that prevented it from fulfilling the request.


1 Answers

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.

like image 76
tvanfosson Avatar answered Oct 06 '22 06:10

tvanfosson