jquery - ASP.NET MVC - Proper way to handle ajax actions with no return object -


I have a controller action that does some work in the database and ends when it ends This verb is being called through a datatype set to 'Jason' via jQuery's AJAX function.

If I set the return operation to zero, then everything will work fine, there will be an error in Firefox. The console says: "No element found".

It is understood that Firefox will throw this error if it expects XML to return. However, when I change the data type property of "text" to AJAX call, I get an error, to get rid of error with return type zero, I have to set the content type of the response to "text / html" or I can set the return type in JasonResult and return a new [empty] JasonResult object.

I am sure there are several ways to overcome this error, but I want to know the proper way to handle the action with returns values ​​called through AXX.

If it matters, then I am also using ASC control action patterns. Public Zero DoSomethingAsync (SomeJsonObjectForModelBinding Models) {// Some Database Things} Public Zero DoSomethingCompleted () {// Nothing to do ... // What should be my type of return? // Do I need to set the content type here? }

I know that this does not answer your question correctly, but I It can be argued that you should always return the return valued with an AJAX or web service call. Even if only to tell you that the operation was successful, or else you would get the error (message) back to you

I often define a class like this: < Pre> public class JsonResultData {private bool _success = true; Public Child Success {} {return _success; } Set {_success = value; }} Public object value {get; Set; } Public listing & lt; String & gt; Errors {receive; Set; } Public JsonResultData () {this.Errors = new list & lt; String & gt; (); }}

and then use it to return data or any other call meta data back to the JasonRisaltadata cover:

  Back to new JSONSUSTAL {data = New Jenson Reset Data {value = return value, success = true}};    

Comments