This is an MVC3 app. I have the following javascript call to my action:
function editDescription(docId,fileName, fileDescription) {
$.ajax({
type: "POST",
url: "/OrderDetail/LoadModelData",
contentType: "application/json; charset=utf-8",
data: "{'id': '"+docId +"', 'filename': '"+fileName+"', 'description': '"+fileDescription+"'}",
dataType: "json",
success: function (result) {
alert("ok: "+ result.d);
},
error: function (result) {
alert('Oh no: '+ result.responseText);
}
});
Heres my action:
[HttpPost]
public string LoadModelData(string id, string filename, string description)
{
return filename;
}
I run the code, the action gets called with the parameters, nothing is null, but the error function gets called every time. So the alert box with 'Oh no' in it appears every time, but the string being returned from the action is correct. If the filename is test.pdf the error alert box says
'Oh No: test.pdf'.
I looked in Firebug and there are no errors. Why isn't the success function being called despite the fact there are no errors?