I have a controller action that does some work in the database and then completes when it is complete. This action is called through a jQuery ajax function with the dataType type set to 'json'.
If I set the return type of the action to void, everything will work fine, except that Firefox will display an error in the console that says: "no element found".
It makes sense that Firefox will throw this error if it expects XML to return. However, even when I change the dataType property of the ajax call to βtextβ, I still get the error. To get rid of the error with the void return type, I would have to set the Response ContentType to "text / html". Or I can set the return type to JsonResult and return a new [empty] JsonResult object.
I am sure there are several ways for this error to disappear, but I wanted to know how to handle actions correctly without returning the values ββcalled through ajax.
If that matters, I also use the asynchronous controller action pattern.
public void DoSomethingAsync(SomeJsonObjectForModelBinding model) { // do some database things } public void DoSomethingCompleted() { // nothing to do... // what should my return type be? // do I need to set the content type here? }
harryfino
source share