Here is my ajax call:
response = $.ajax({
type: "POST",
url: "/Row/getRowName",
dataType: "json",
data:({ currRow : rowName, offset : 5 }),
error:function(request){alert(request.statusText)},
success:function(result){alert(result)}
}).responseText;
I get Internal Server Error as an alert. I also have a breakpoint set in my method getRowName in my RowController.
Here's the getRowName method:
[AcceptVerbs(HttpVerbs.Post)]
public string getRowName(string currRow, int offset)
{
string rowName;
rowName = _rowRepository.getRowNameByOffset(currRow, offset);
return rowName;
}
What causes an Internal Server Error? How can I fix it? Am I using the whole controller concept properly or should I be using WebServices for things like this?
Edit: The controller that calls the page is HomeController where as the call I'm making is to RowController. RowController is in the same folder as HomeController (not sure if that matters).
But I found out if I create a mock function:
[AcceptVerbs(HttpVerbs.Post)]
public string sayHi()
{
return "Hi";
}
and calling it the same way (different url since it's in the home controller):
response = $.ajax({
type: "POST",
url: "/Home/sayHi",
dataType: "json",
error:function(request){alert(request.statusText)},
success:function(result){alert(result)}
}).responseText;
Any ideas as to why this would work and the other wouldn't?